diff options
author | Erik Johnston <erik@matrix.org> | 2015-05-13 11:22:42 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-05-13 11:22:42 +0100 |
commit | fec4485e28569718b9a0c341be4aaead8533c280 (patch) | |
tree | 7494f90787ef54e3a44c8f4d530acbfee31d584e /synapse/storage | |
parent | Load events for state group seperately (diff) | |
download | synapse-fec4485e28569718b9a0c341be4aaead8533c280.tar.xz |
Batch fetching of events for state groups
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/state.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 9ed5412999..c300c6e29c 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -83,8 +83,31 @@ class StateStore(SQLBaseStore): f, ) + def fetch_events(txn, events): + sql = ( + "SELECT e.internal_metadata, e.json, r.event_id, rej.reason " + " FROM event_json as e" + " LEFT JOIN redactions as r ON e.event_id = r.redacts" + " LEFT JOIN rejections as rej on rej.event_id = e.event_id" + " WHERE e.event_id IN (%s)" + ) % (",".join(["?"]*len(events)),) + + txn.execute(sql, events) + rows = txn.fetchall() + + return [ + self._get_event_from_row_txn( + txn, row[0], row[1], row[2], + rejected_reason=row[3], + ) + for row in rows + ] + for vals in states.values(): - vals[:] = yield self._get_events(vals, desc="_get_state_groups_ev") + vals[:] = yield self.runInteraction( + "_get_state_groups_ev", + fetch_events, vals + ) defer.returnValue(states) |