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/events.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/events.py')
-rw-r--r-- | synapse/storage/events.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py index 03881ea3dc..72319c35ae 100644 --- a/synapse/storage/events.py +++ b/synapse/storage/events.py @@ -467,14 +467,9 @@ class EventsStore(SQLBaseStore): else: return - existing_state_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", - ) + existing_state = yield self.get_current_state_ids(room_id) - existing_events = set(row["event_id"] for row in existing_state_rows) + existing_events = set(existing_state.itervalues()) new_events = set(ev_id for ev_id in current_state.itervalues()) changed_events = existing_events ^ new_events @@ -482,9 +477,8 @@ class EventsStore(SQLBaseStore): return to_delete = { - (row["type"], row["state_key"]): row["event_id"] - for row in existing_state_rows - if row["event_id"] in changed_events + key: ev_id for key, ev_id in existing_state.iteritems() + if ev_id in changed_events } events_to_insert = (new_events - existing_events) to_insert = { @@ -610,6 +604,10 @@ class EventsStore(SQLBaseStore): txn, self.get_users_in_room, (room_id,) ) + self._invalidate_cache_and_stream( + txn, self.get_current_state_ids, (room_id,) + ) + for room_id, new_extrem in new_forward_extremeties.items(): self._simple_delete_txn( txn, |