summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorErik Johnston <erikj@jki.re>2017-02-01 11:44:27 +0000
committerGitHub <noreply@github.com>2017-02-01 11:44:27 +0000
commit88a4d54883d64c8059cde1f8215d7e97644dac85 (patch)
treede27b029701026f1333589aea838e0fe0ba078c6 /synapse/storage/state.py
parentUp get_latest_event_ids_in_room cache (diff)
parentAdd an index to make membership queries faster (diff)
downloadsynapse-88a4d54883d64c8059cde1f8215d7e97644dac85.tar.xz
Merge pull request #1867 from matrix-org/erikj/member_index
Add an index to make membership queries faster
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r--synapse/storage/state.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py
index d1d653327c..1b3800eb6a 100644
--- a/synapse/storage/state.py
+++ b/synapse/storage/state.py
@@ -49,6 +49,7 @@ class StateStore(SQLBaseStore):
 
     STATE_GROUP_DEDUPLICATION_UPDATE_NAME = "state_group_state_deduplication"
     STATE_GROUP_INDEX_UPDATE_NAME = "state_group_state_type_index"
+    CURRENT_STATE_INDEX_UPDATE_NAME = "current_state_members_idx"
 
     def __init__(self, hs):
         super(StateStore, self).__init__(hs)
@@ -60,6 +61,13 @@ class StateStore(SQLBaseStore):
             self.STATE_GROUP_INDEX_UPDATE_NAME,
             self._background_index_state,
         )
+        self.register_background_index_update(
+            self.CURRENT_STATE_INDEX_UPDATE_NAME,
+            index_name="current_state_events_member_index",
+            table="current_state_events",
+            columns=["state_key"],
+            where_clause="type='m.room.member'",
+        )
 
     @defer.inlineCallbacks
     def get_state_groups_ids(self, room_id, event_ids):