Skip to content
Snippets Groups Projects
Commit 5ac75fc9 authored by Erik Johnston's avatar Erik Johnston
Browse files

Join against events to use its room_id index

parent e2c46ed8
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment