summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2016-09-07 14:22:22 +0100
committerErik Johnston <erik@matrix.org>2016-09-07 14:22:22 +0100
commitd25c20ccbe0f10fe5d6c0cef2156db7e8d76049c (patch)
tree459077880edcf4029a0c27eeae369c36645b0de1 /synapse
parentMerge pull request #1065 from matrix-org/erikj/state_storage (diff)
downloadsynapse-d25c20ccbe0f10fe5d6c0cef2156db7e8d76049c.tar.xz
Use windowing function to make use of index
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/state.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py

index 0730399b80..26ecad5907 100644 --- a/synapse/storage/state.py +++ b/synapse/storage/state.py
@@ -322,11 +322,11 @@ class StateStore(SQLBaseStore): SELECT prev_state_group FROM state_group_edges e, state s WHERE s.state_group = e.state_group ) - SELECT type, state_key, event_id FROM state_groups_state - WHERE ROW(type, state_key, state_group) IN ( - SELECT type, state_key, max(state_group) FROM state - INNER JOIN state_groups_state USING (state_group) - GROUP BY type, state_key + SELECT type, state_key, last_value(event_id) OVER ( + PARTITION BY type, state_key ORDER BY state_group ASC + ) AS event_id FROM state_groups_state + WHERE state_group IN ( + SELECT state_group FROM state ) %s; """) % (where_clause,)