diff options
author | Erik Johnston <erik@matrix.org> | 2015-01-22 13:37:44 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-01-22 13:37:44 +0000 |
commit | 33d2d82f6d2dae17038965e86f56cb1e09b36d6c (patch) | |
tree | a5e3a92f5a10d278e889d86be6936d5f65079a4b | |
parent | Move experiments, graph and cmdclient into contrib (diff) | |
download | synapse-33d2d82f6d2dae17038965e86f56cb1e09b36d6c.tar.xz |
In get_state_groups, get the full event json rather than just the event_ids so we don't have to do so many db queries
-rw-r--r-- | synapse/storage/state.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py index 71db16d0e5..e94c8fcd18 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py @@ -60,14 +60,19 @@ class StateStore(SQLBaseStore): res = {} for group in groups: - state_ids = self._simple_select_onecol_txn( - txn, - table="state_groups_state", - keyvalues={"state_group": group}, - retcol="event_id", + sql = ( + "SELECT internal_metadata, json, r.event_id " + "FROM event_json as e " + "INNER JOIN state_groups_state as s " + "ON e.event_id = s.event_id " + "LEFT JOIN redactions as r ON e.event_id = r.redacts " + "WHERE s.state_group = ?" ) - state = self._get_events_txn(txn, state_ids) + txn.execute(sql, (group,)) + rows = txn.fetchall() + + state = [self._get_event_from_row_txn(txn, *r) for r in rows] res[group] = state |