Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 6c70419

Browse files
committed
Merge pull request #5713 from matrix-org/erikj/use_cache_for_filtered_state
2 parents 04d4c31 + d7bd965 commit 6c70419

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

changelog.d/5713.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Improve caching when fetching `get_filtered_current_state_ids`.

synapse/storage/state.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,19 @@ def get_filtered_current_state_ids(self, room_id, state_filter=StateFilter.all()
510510
event ID.
511511
"""
512512

513+
where_clause, where_args = state_filter.make_sql_filter_clause()
514+
515+
if not where_clause:
516+
# We delegate to the cached version
517+
return self.get_current_state_ids(room_id)
518+
513519
def _get_filtered_current_state_ids_txn(txn):
514520
results = {}
515521
sql = """
516522
SELECT type, state_key, event_id FROM current_state_events
517523
WHERE room_id = ?
518524
"""
519525

520-
where_clause, where_args = state_filter.make_sql_filter_clause()
521-
522526
if where_clause:
523527
sql += " AND (%s)" % (where_clause,)
524528

0 commit comments

Comments
 (0)