diff options
author | Erik Johnston <erik@matrix.org> | 2015-01-22 13:58:25 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-01-22 14:01:10 +0000 |
commit | 03c0da9f65ce2fb9752aacd6a85419a000d86ff0 (patch) | |
tree | 004f5b2209daf24dea60611eec4473a0dc6336cd | |
parent | In get_state_groups, get the full event json rather than just the event_ids s... (diff) | |
download | synapse-github/get_state_groups-perf.tar.xz |
In get_recent_events_for_room, get the full event json rather than just the event_ids so we don't have to do so many db queries github/get_state_groups-perf get_state_groups-perf
-rw-r--r-- | synapse/storage/stream.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/synapse/storage/stream.py b/synapse/storage/stream.py index 8ac2adab05..12eacb91c0 100644 --- a/synapse/storage/stream.py +++ b/synapse/storage/stream.py @@ -269,8 +269,11 @@ class StreamStore(SQLBaseStore): # TODO (erikj): Handle compressed feedback sql = ( - "SELECT stream_ordering, topological_ordering, event_id FROM events " - "WHERE room_id = ? AND stream_ordering <= ? AND outlier = 0 " + "SELECT stream_ordering, topological_ordering, " + "internal_metadata, json, r.event_id FROM events as e " + "LEFT JOIN event_json as ej ON e.event_id = ej.event_id " + "LEFT JOIN redactions as r ON e.event_id = r.redacts " + "WHERE e.room_id = ? AND stream_ordering <= ? AND outlier = 0 " "ORDER BY topological_ordering DESC, stream_ordering DESC LIMIT ? " ) @@ -295,11 +298,15 @@ class StreamStore(SQLBaseStore): else: token = (end_token, end_token) - events = self._get_events_txn( - txn, - [r["event_id"] for r in rows], - get_prev_content=True - ) + events = [ + self._get_event_from_row_txn( + txn, + r["internal_metadata"], + r["json"], + r["event_id"], + ) + for r in rows + ] return events, token |