From 10523241d86eeaa1fa43607a03352f9e7b04efda Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 18 Jul 2019 15:17:37 +0100 Subject: [PATCH 1/2] Delegate to cached version when using get_filtered_current_state_ids In the case where it gets called with `StateFilter.all()` --- synapse/storage/state.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 0bfe1b455..a35289876 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -510,6 +510,12 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore): 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 = """ @@ -517,8 +523,6 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore): WHERE room_id = ? """ - where_clause, where_args = state_filter.make_sql_filter_clause() - if where_clause: sql += " AND (%s)" % (where_clause,) From dd2851d576649194205725bb5105f3cbb4a87e55 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 18 Jul 2019 15:27:18 +0100 Subject: [PATCH 2/2] Newsfile --- changelog.d/5713.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5713.misc diff --git a/changelog.d/5713.misc b/changelog.d/5713.misc new file mode 100644 index 000000000..01ea1cf8d --- /dev/null +++ b/changelog.d/5713.misc @@ -0,0 +1 @@ +Improve caching when fetching `get_filtered_current_state_ids`.