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

Commit

Permalink
Merge pull request #5713 from matrix-org/erikj/use_cache_for_filtered…
Browse files Browse the repository at this point in the history
…_state

Delegate to cached version when using get_filtered_current_state_ids
  • Loading branch information
erikjohnston authored Jul 19, 2019
2 parents 5c07c97 + dd2851d commit d7bd965
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
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

0 comments on commit d7bd965

Please sign in to comment.