mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Remove some redundant joins on event_edges.room_id
We've long passed the point where it's possible to have the same event_id in different tables, so these join conditions are redundant: we can just join on event_id. event_edges is of non-trivial size, and the room_id column is wasteful, so let's stop reading from it. In future, we can stop writing to it, and then drop it.
This commit is contained in:
parent
1b4d73fa52
commit
bd4b25f4d0
@ -114,9 +114,9 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
|
|||||||
sql = (
|
sql = (
|
||||||
"SELECT b.event_id, MAX(e.depth) FROM events as e"
|
"SELECT b.event_id, MAX(e.depth) FROM events as e"
|
||||||
" INNER JOIN event_edges as g"
|
" INNER JOIN event_edges as g"
|
||||||
" ON g.event_id = e.event_id AND g.room_id = e.room_id"
|
" ON g.event_id = e.event_id"
|
||||||
" INNER JOIN event_backward_extremities as b"
|
" INNER JOIN event_backward_extremities as b"
|
||||||
" ON g.prev_event_id = b.event_id AND g.room_id = b.room_id"
|
" ON g.prev_event_id = b.event_id"
|
||||||
" WHERE b.room_id = ? AND g.is_state is ?"
|
" WHERE b.room_id = ? AND g.is_state is ?"
|
||||||
" GROUP BY b.event_id"
|
" GROUP BY b.event_id"
|
||||||
)
|
)
|
||||||
@ -330,8 +330,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
|
|||||||
"SELECT depth, prev_event_id FROM event_edges"
|
"SELECT depth, prev_event_id FROM event_edges"
|
||||||
" INNER JOIN events"
|
" INNER JOIN events"
|
||||||
" ON prev_event_id = events.event_id"
|
" ON prev_event_id = events.event_id"
|
||||||
" AND event_edges.room_id = events.room_id"
|
" WHERE event_edges.event_id = ?"
|
||||||
" WHERE event_edges.room_id = ? AND event_edges.event_id = ?"
|
|
||||||
" AND event_edges.is_state = ?"
|
" AND event_edges.is_state = ?"
|
||||||
" LIMIT ?"
|
" LIMIT ?"
|
||||||
)
|
)
|
||||||
@ -365,7 +364,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
|
|||||||
|
|
||||||
txn.execute(
|
txn.execute(
|
||||||
query,
|
query,
|
||||||
(room_id, event_id, False, limit - len(event_results))
|
(event_id, False, limit - len(event_results))
|
||||||
)
|
)
|
||||||
|
|
||||||
for row in txn:
|
for row in txn:
|
||||||
@ -402,7 +401,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
|
|||||||
|
|
||||||
query = (
|
query = (
|
||||||
"SELECT prev_event_id FROM event_edges "
|
"SELECT prev_event_id FROM event_edges "
|
||||||
"WHERE room_id = ? AND event_id = ? AND is_state = ? "
|
"WHERE event_id = ? AND is_state = ? "
|
||||||
"LIMIT ?"
|
"LIMIT ?"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -411,7 +410,7 @@ class EventFederationWorkerStore(EventsWorkerStore, SignatureWorkerStore,
|
|||||||
for event_id in front:
|
for event_id in front:
|
||||||
txn.execute(
|
txn.execute(
|
||||||
query,
|
query,
|
||||||
(room_id, event_id, False, limit - len(event_results))
|
(event_id, False, limit - len(event_results))
|
||||||
)
|
)
|
||||||
|
|
||||||
for e_id, in txn:
|
for e_id, in txn:
|
||||||
|
@ -520,7 +520,6 @@ class EventsStore(EventsWorkerStore):
|
|||||||
iterable=list(new_latest_event_ids),
|
iterable=list(new_latest_event_ids),
|
||||||
retcols=["prev_event_id"],
|
retcols=["prev_event_id"],
|
||||||
keyvalues={
|
keyvalues={
|
||||||
"room_id": room_id,
|
|
||||||
"is_state": False,
|
"is_state": False,
|
||||||
},
|
},
|
||||||
desc="_calculate_new_extremeties",
|
desc="_calculate_new_extremeties",
|
||||||
|
Loading…
Reference in New Issue
Block a user