From 33d2d82f6d2dae17038965e86f56cb1e09b36d6c Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Thu, 22 Jan 2015 13:37:44 +0000 Subject: [PATCH] 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 --- synapse/storage/state.py | 17 +++++++++++------ 1 file 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