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

Delegate to cached version when using get_filtered_current_state_ids #5713

Merged
merged 2 commits into from
Jul 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/5713.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve caching when fetching `get_filtered_current_state_ids`.
8 changes: 6 additions & 2 deletions synapse/storage/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,15 +510,19 @@ def get_filtered_current_state_ids(self, room_id, state_filter=StateFilter.all()
event ID.
"""

where_clause, where_args = state_filter.make_sql_filter_clause()

if not where_clause:
# We delegate to the cached version
return self.get_current_state_ids(room_id)

def _get_filtered_current_state_ids_txn(txn):
results = {}
sql = """
SELECT type, state_key, event_id FROM current_state_events
WHERE room_id = ?
"""

where_clause, where_args = state_filter.make_sql_filter_clause()

if where_clause:
sql += " AND (%s)" % (where_clause,)

Expand Down