diff options
author | Erik Johnston <erikj@jki.re> | 2017-03-14 16:58:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-14 16:58:26 +0000 |
commit | 1bf84c4b6b9e2a145fcc8cfd27cbb2775746378a (patch) | |
tree | ae6d19a234b566ff4fc58ec1d7b47c9622843b2c /synapse/storage/state.py | |
parent | Merge pull request #1996 from matrix-org/erikj/fix_current_state (diff) | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj/public_lis... (diff) | |
download | synapse-1bf84c4b6b9e2a145fcc8cfd27cbb2775746378a.tar.xz |
Merge pull request #1989 from matrix-org/erikj/public_list_speed
Speed up public room list
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r-- | synapse/storage/state.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 84482d8285..27f1ec89ec 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -14,7 +14,7 @@ # limitations under the License. from ._base import SQLBaseStore -from synapse.util.caches.descriptors import cached, cachedList +from synapse.util.caches.descriptors import cached, cachedList, cachedInlineCallbacks from synapse.util.caches import intern_string from synapse.storage.engines import PostgresEngine @@ -69,6 +69,18 @@ class StateStore(SQLBaseStore): where_clause="type='m.room.member'", ) + @cachedInlineCallbacks(max_entries=100000, iterable=True) + def get_current_state_ids(self, room_id): + rows = yield self._simple_select_list( + table="current_state_events", + keyvalues={"room_id": room_id}, + retcols=["event_id", "type", "state_key"], + desc="_calculate_state_delta", + ) + defer.returnValue({ + (r["type"], r["state_key"]): r["event_id"] for r in rows + }) + @defer.inlineCallbacks def get_state_groups_ids(self, room_id, event_ids): if not event_ids: |