summary refs log tree commit diff
path: root/synapse/storage/roommember.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-01-06 13:33:40 +0000
committerMark Haines <mjark@negativecurvature.net>2015-01-06 13:33:40 +0000
commit5e23a192040cefcade3048db33fae09accf61a6a (patch)
tree0a38b94e77dd8bfbaba650b5fa9c943c230a4e37 /synapse/storage/roommember.py
parentUpdate copyright notices (diff)
parentPEP8 (diff)
downloadsynapse-5e23a192040cefcade3048db33fae09accf61a6a.tar.xz
Merge pull request #28 from matrix-org/erikj-perf
Database performance improvements.
Diffstat (limited to 'synapse/storage/roommember.py')
-rw-r--r--synapse/storage/roommember.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/synapse/storage/roommember.py b/synapse/storage/roommember.py
index 127434d27a..27b7d8eb13 100644
--- a/synapse/storage/roommember.py
+++ b/synapse/storage/roommember.py
@@ -123,6 +123,19 @@ class RoomMemberStore(SQLBaseStore):
         else:
             return None
 
+    def get_users_in_room(self, room_id):
+        def f(txn):
+            sql = (
+                "SELECT m.user_id FROM room_memberships as m"
+                " INNER JOIN current_state_events as c"
+                " ON m.event_id = c.event_id"
+                " WHERE m.membership = ? AND m.room_id = ?"
+            )
+
+            txn.execute(sql, (Membership.JOIN, room_id))
+            return [r[0] for r in txn.fetchall()]
+        return self.runInteraction("get_users_in_room", f)
+
     def get_room_members(self, room_id, membership=None):
         """Retrieve the current room member list for a room.
 
@@ -183,20 +196,14 @@ class RoomMemberStore(SQLBaseStore):
         )
 
     def _get_members_query_txn(self, txn, where_clause, where_values):
-        del_sql = (
-            "SELECT event_id FROM redactions WHERE redacts = e.event_id "
-            "LIMIT 1"
-        )
-
         sql = (
-            "SELECT e.*, (%(redacted)s) AS redacted FROM events as e "
+            "SELECT e.* FROM events as e "
             "INNER JOIN room_memberships as m "
             "ON e.event_id = m.event_id "
             "INNER JOIN current_state_events as c "
             "ON m.event_id = c.event_id "
             "WHERE %(where)s "
         ) % {
-            "redacted": del_sql,
             "where": where_clause,
         }