summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-04-30 18:41:05 +0100
committerErik Johnston <erik@matrix.org>2015-04-30 18:41:05 +0100
commit61d05daab1ab4e00f40195cd0c81a88cdedb9632 (patch)
treeb17f5846b155554dd0de169cb80d254abf8187b0 /synapse/storage/roommember.py
parentAdd more conditions on JOINs to make postgres go a little faster. (diff)
downloadsynapse-61d05daab1ab4e00f40195cd0c81a88cdedb9632.tar.xz
More join conditions
Diffstat (limited to '')
-rw-r--r--synapse/storage/roommember.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 2952c62f20..09fb77a194 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -154,7 +154,9 @@ class RoomMemberStore(SQLBaseStore):
             "SELECT m.room_id, m.sender, m.membership"
             " FROM room_memberships as m"
             " 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 "
+            " AND m.user_id = c.state_key"
             " WHERE %s"
         ) % (where_clause,)
 
@@ -212,7 +214,9 @@ class RoomMemberStore(SQLBaseStore):
         sql = (
             "SELECT m.* FROM room_memberships as m"
             " INNER JOIN current_state_events as c"
-            " ON m.event_id = c.event_id AND m.room_id = c.room_id "
+            " ON m.event_id = c.event_id "
+            " AND m.room_id = c.room_id "
+            " AND m.user_id = c.state_key"
             " WHERE %(where)s"
         ) % {
             "where": where_clause,