mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-15 22:20:15 -04:00
Add event_stream_ordering
column to membership state tables (#14979)
This adds an `event_stream_ordering` column to `current_state_events`, `local_current_membership` and `room_memberships`. Each of these tables is regularly joined with the `events` table to get the stream ordering and denormalising this into each table will yield significant query performance improvements once used. Includes a background job to populate these values from the `events` table. Same idea as https://github.com/matrix-org/synapse/pull/13703. Signed off by Nick @ Beeper (@fizzadar).
This commit is contained in:
parent
64a631879c
commit
5fdc12f482
5 changed files with 146 additions and 11 deletions
|
@ -1779,7 +1779,7 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
txn: LoggingTransaction,
|
||||
) -> List[Tuple[int, str, str, str, str, str, str, str, bool, bool]]:
|
||||
sql = (
|
||||
"SELECT event_stream_ordering, e.event_id, e.room_id, e.type,"
|
||||
"SELECT out.event_stream_ordering, e.event_id, e.room_id, e.type,"
|
||||
" se.state_key, redacts, relates_to_id, membership, rejections.reason IS NOT NULL,"
|
||||
" e.outlier"
|
||||
" FROM events AS e"
|
||||
|
@ -1791,10 +1791,10 @@ class EventsWorkerStore(SQLBaseStore):
|
|||
" LEFT JOIN event_relations USING (event_id)"
|
||||
" LEFT JOIN room_memberships USING (event_id)"
|
||||
" LEFT JOIN rejections USING (event_id)"
|
||||
" WHERE ? < event_stream_ordering"
|
||||
" AND event_stream_ordering <= ?"
|
||||
" WHERE ? < out.event_stream_ordering"
|
||||
" AND out.event_stream_ordering <= ?"
|
||||
" AND out.instance_name = ?"
|
||||
" ORDER BY event_stream_ordering ASC"
|
||||
" ORDER BY out.event_stream_ordering ASC"
|
||||
)
|
||||
|
||||
txn.execute(sql, (last_id, current_id, instance_name))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue