summary refs log tree commit diff
path: root/synapse/storage/events_worker.py
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-05-31 11:38:13 +0100
committerRichard van der Hoff <richard@matrix.org>2019-05-31 11:38:13 +0100
commitc605da97bff8dc749ebea1fc016f231461b2c19f (patch)
tree8a1f131272010881b97c215e4a5518dd1ebc4735 /synapse/storage/events_worker.py
parentRewrite get_server_verify_keys, again. (diff)
parentMerge pull request #5300 from matrix-org/rav/server_keys/06-fix-serverkeys-ha... (diff)
downloadsynapse-c605da97bff8dc749ebea1fc016f231461b2c19f.tar.xz
Merge remote-tracking branch 'origin/develop' into rav/server_keys/05-rewrite-gsvk-again
Diffstat (limited to 'synapse/storage/events_worker.py')
-rw-r--r--synapse/storage/events_worker.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/synapse/storage/events_worker.py b/synapse/storage/events_worker.py
index b56c83e460..1782428048 100644
--- a/synapse/storage/events_worker.py
+++ b/synapse/storage/events_worker.py
@@ -618,7 +618,12 @@ class EventsWorkerStore(SQLBaseStore):
         """
         See get_total_state_event_counts.
         """
-        sql = "SELECT COUNT(*) FROM state_events WHERE room_id=?"
+        # We join against the events table as that has an index on room_id
+        sql = """
+            SELECT COUNT(*) FROM state_events
+            INNER JOIN events USING (room_id, event_id)
+            WHERE room_id=?
+        """
         txn.execute(sql, (room_id,))
         row = txn.fetchone()
         return row[0] if row else 0