mirror of
https://github.com/element-hq/synapse
synced 2024-09-04 19:30:06 +00:00
Use windowing function to make use of index
This commit is contained in:
parent
94a83b534f
commit
d25c20ccbe
1 changed files with 5 additions and 5 deletions
|
@ -322,11 +322,11 @@ class StateStore(SQLBaseStore):
|
||||||
SELECT prev_state_group FROM state_group_edges e, state s
|
SELECT prev_state_group FROM state_group_edges e, state s
|
||||||
WHERE s.state_group = e.state_group
|
WHERE s.state_group = e.state_group
|
||||||
)
|
)
|
||||||
SELECT type, state_key, event_id FROM state_groups_state
|
SELECT type, state_key, last_value(event_id) OVER (
|
||||||
WHERE ROW(type, state_key, state_group) IN (
|
PARTITION BY type, state_key ORDER BY state_group ASC
|
||||||
SELECT type, state_key, max(state_group) FROM state
|
) AS event_id FROM state_groups_state
|
||||||
INNER JOIN state_groups_state USING (state_group)
|
WHERE state_group IN (
|
||||||
GROUP BY type, state_key
|
SELECT state_group FROM state
|
||||||
)
|
)
|
||||||
%s;
|
%s;
|
||||||
""") % (where_clause,)
|
""") % (where_clause,)
|
||||||
|
|
Loading…
Reference in a new issue