-
Notifications
You must be signed in to change notification settings - Fork 290
feat(event cache): rework the SQL schema #4849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ir position in a chunk
…t into the database
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4849 +/- ##
==========================================
+ Coverage 86.47% 86.50% +0.02%
==========================================
Files 297 297
Lines 34636 34756 +120
==========================================
+ Hits 29951 30065 +114
- Misses 4685 4691 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
As expected, this is a small performance hit when reading (because there's an extra join) around 7% of a time increase at the limit; when writing it's a speedup (time reduced by 5%), and the only reason I can fathom is that the Benchmark
|
…n handle indexed items This is necessary to save out-of-band items into the relational linked chunk. I'm not quite sure of the value to keep it generic, at this point, but at least it makes testing easy.
Getting the position when reading an event is no longer required: - the only use case for reading the position out of the event cache was when we wanted to replace a redacted item into the linked chunk; now with save_event(), we can replace it without having to know its position. As an extra measure of caution, I've also included the room_id in the `events` table, next to the event_id, so that looking for an event is still restricted to a single room.
…id, with or without its relations
…getting an event's relations
…plies It's unclear whether it's useful, especially in the case where it would return an entire reply chain. It's not possible to filter in replies only, using the function either, which is a sign that replies shouldn't be indexed, IMO. In any case, that's something we can add back in the future, if we want to.
…daction events A redaction event would be either applied a priori (by the server, when returning the sync response), or the event cache would handle it, and redact it in the database; in any case, we'd never see the original event in its non-redacted form, so there's no point in returning the redaction event itself.
531e3e1
to
4b0a55a
Compare
…with_relations` And rename it `find_event_relations`.
… delete all the events' contents
And fix the sql backend \o/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great job, thanks for all this, pretty exciting to see AllEventCache
being removed, finally!
I've a couple of feedback, but nothing fancy. The biggest question is about a cascading deletion between events_chunks
and events
.
crates/matrix-sdk-sqlite/migrations/event_cache_store/007_events_chunks.sql
Outdated
Show resolved
Hide resolved
crates/matrix-sdk-sqlite/migrations/event_cache_store/007_events_chunks.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving in advance knowing all questions will be addressed.
…chunks And some comments have been tweaked too.
This rejiggers the event cache's store schema so that events can be saved independently of their position in a linked chunk. Also, it makes it possible to extract an event's relation metadata, so we can get rid of the
AllEventsCache
along the way.Fixes #4841.
Fixes #3886.
Part of #3280.
Remaining steps:
AllEventsCache
save_event()
methodfind_event_relations()
methodKind of depending on ruma/ruma#2052, although we don't really have to.