mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-22 19:25:00 -05:00
Add more conditions on JOINs to make postgres go a little faster.
This commit is contained in:
parent
f383d5a801
commit
6ead27ddda
@ -212,7 +212,7 @@ class RoomMemberStore(SQLBaseStore):
|
|||||||
sql = (
|
sql = (
|
||||||
"SELECT m.* FROM room_memberships as m"
|
"SELECT m.* FROM room_memberships as m"
|
||||||
" INNER JOIN current_state_events as c"
|
" INNER JOIN current_state_events as c"
|
||||||
" ON m.event_id = c.event_id"
|
" ON m.event_id = c.event_id AND m.room_id = c.room_id "
|
||||||
" WHERE %(where)s"
|
" WHERE %(where)s"
|
||||||
) % {
|
) % {
|
||||||
"where": where_clause,
|
"where": where_clause,
|
||||||
|
@ -149,7 +149,8 @@ class StreamStore(SQLBaseStore):
|
|||||||
# select all the events between from/to with a sensible limit
|
# select all the events between from/to with a sensible limit
|
||||||
sql = (
|
sql = (
|
||||||
"SELECT e.event_id, e.room_id, e.type, s.state_key, "
|
"SELECT e.event_id, e.room_id, e.type, s.state_key, "
|
||||||
"e.stream_ordering FROM events AS e LEFT JOIN state_events as s ON "
|
"e.stream_ordering FROM events AS e "
|
||||||
|
"LEFT JOIN state_events as s ON "
|
||||||
"e.event_id = s.event_id "
|
"e.event_id = s.event_id "
|
||||||
"WHERE e.stream_ordering > ? AND e.stream_ordering <= ? "
|
"WHERE e.stream_ordering > ? AND e.stream_ordering <= ? "
|
||||||
"ORDER BY stream_ordering ASC LIMIT %(limit)d "
|
"ORDER BY stream_ordering ASC LIMIT %(limit)d "
|
||||||
@ -214,8 +215,9 @@ class StreamStore(SQLBaseStore):
|
|||||||
|
|
||||||
current_room_membership_sql = (
|
current_room_membership_sql = (
|
||||||
"SELECT m.room_id FROM room_memberships as m "
|
"SELECT m.room_id FROM room_memberships as m "
|
||||||
"INNER JOIN current_state_events as c ON m.event_id = c.event_id "
|
" INNER JOIN current_state_events as c"
|
||||||
"WHERE m.user_id = ? AND m.membership = 'join'"
|
" ON m.event_id = c.event_id AND c.state_key = m.user_id"
|
||||||
|
" WHERE m.user_id = ? AND m.membership = 'join'"
|
||||||
)
|
)
|
||||||
|
|
||||||
# We also want to get any membership events about that user, e.g.
|
# We also want to get any membership events about that user, e.g.
|
||||||
|
Loading…
Reference in New Issue
Block a user