summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-04 15:24:01 +0100
committerErik Johnston <erik@matrix.org>2018-10-04 16:03:08 +0100
commit4917ff55234718c0e650c6dc2a1117304465b9be (patch)
treed7f51bf4691b1f4ed22c039a3a0a8a32e331320b /synapse/storage/state.py
parentDelete unreferened state groups during purge (diff)
downloadsynapse-4917ff55234718c0e650c6dc2a1117304465b9be.tar.xz
Add state_group index to event_to_state_groups
This is needed to efficiently check for unreferenced state groups during
purge.
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r--synapse/storage/state.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py
index b88c7dc091..3f08f447a3 100644
--- a/synapse/storage/state.py
+++ b/synapse/storage/state.py
@@ -1114,6 +1114,7 @@ class StateStore(StateGroupWorkerStore, BackgroundUpdateStore):
     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"
+    EVENT_STATE_GROUP_INDEX_UPDATE_NAME = "event_to_state_groups_sg_index"
 
     def __init__(self, db_conn, hs):
         super(StateStore, self).__init__(db_conn, hs)
@@ -1132,6 +1133,12 @@ class StateStore(StateGroupWorkerStore, BackgroundUpdateStore):
             columns=["state_key"],
             where_clause="type='m.room.member'",
         )
+        self.register_background_index_update(
+            self.EVENT_STATE_GROUP_INDEX_UPDATE_NAME,
+            index_name="event_to_state_groups_sg_index",
+            table="event_to_state_groups",
+            columns=["state_group"],
+        )
 
     def _store_event_state_mappings_txn(self, txn, events_and_contexts):
         state_groups = {}