Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #3613 from matrix-org/rav/stop_using_event_edges_r…
Browse files Browse the repository at this point in the history
…oom_id

Remove some redundant joins on event_edges.room_id
  • Loading branch information
richvdh authored Jul 26, 2018
2 parents ef9d51b + cf78eae commit 9e68b1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions changelog.d/3613.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove some redundant joins on event_edges.room_id
13 changes: 6 additions & 7 deletions synapse/storage/event_federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def get_oldest_events_with_depth_in_room_txn(self, txn, room_id):
sql = (
"SELECT b.event_id, MAX(e.depth) FROM events as e"
" 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"
" 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 ?"
" GROUP BY b.event_id"
)
Expand Down Expand Up @@ -330,8 +330,7 @@ def _get_backfill_events(self, txn, room_id, event_list, limit):
"SELECT depth, prev_event_id FROM event_edges"
" INNER JOIN events"
" ON prev_event_id = events.event_id"
" AND event_edges.room_id = events.room_id"
" WHERE event_edges.room_id = ? AND event_edges.event_id = ?"
" WHERE event_edges.event_id = ?"
" AND event_edges.is_state = ?"
" LIMIT ?"
)
Expand Down Expand Up @@ -365,7 +364,7 @@ def _get_backfill_events(self, txn, room_id, event_list, limit):

txn.execute(
query,
(room_id, event_id, False, limit - len(event_results))
(event_id, False, limit - len(event_results))
)

for row in txn:
Expand Down Expand Up @@ -402,7 +401,7 @@ def _get_missing_events(self, txn, room_id, earliest_events, latest_events,

query = (
"SELECT prev_event_id FROM event_edges "
"WHERE room_id = ? AND event_id = ? AND is_state = ? "
"WHERE event_id = ? AND is_state = ? "
"LIMIT ?"
)

Expand All @@ -411,7 +410,7 @@ def _get_missing_events(self, txn, room_id, earliest_events, latest_events,
for event_id in front:
txn.execute(
query,
(room_id, event_id, False, limit - len(event_results))
(event_id, False, limit - len(event_results))
)

for e_id, in txn:
Expand Down
1 change: 0 additions & 1 deletion synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ def _calculate_new_extremeties(self, room_id, event_contexts, latest_event_ids):
iterable=list(new_latest_event_ids),
retcols=["prev_event_id"],
keyvalues={
"room_id": room_id,
"is_state": False,
},
desc="_calculate_new_extremeties",
Expand Down

0 comments on commit 9e68b1b

Please sign in to comment.