mirror of
https://github.com/element-hq/synapse
synced 2024-08-30 12:20:20 +00:00
Join against events to use its room_id index
This commit is contained in:
parent
e2c46ed851
commit
5ac75fc9a2
1 changed files with 6 additions and 1 deletions
|
@ -618,7 +618,12 @@ class EventsWorkerStore(SQLBaseStore):
|
||||||
"""
|
"""
|
||||||
See get_total_state_event_counts.
|
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,))
|
txn.execute(sql, (room_id,))
|
||||||
row = txn.fetchone()
|
row = txn.fetchone()
|
||||||
return row[0] if row else 0
|
return row[0] if row else 0
|
||||||
|
|
Loading…
Reference in a new issue