summary refs log tree commit diff
path: root/synapse/storage/events_worker.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-05-31 10:48:51 +0100
committerGitHub <noreply@github.com>2019-05-31 10:48:51 +0100
commit31d44ec4bd466e938bd6d8d00b2629f5f7ca00a5 (patch)
treebcb9628435a9012e0f64bacc5f1341e08305541e /synapse/storage/events_worker.py
parentClarify that the admin change password endpoint logs them out (#5303) (diff)
parentNewsfile (diff)
downloadsynapse-31d44ec4bd466e938bd6d8d00b2629f5f7ca00a5.tar.xz
Merge pull request #5294 from matrix-org/erikj/speed_up_room_stats
Speed up room stats background update
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