diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2020-12-16 18:16:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-16 18:16:39 +0000 |
commit | e1ace7e44a20be00a6db8905e5923094a37dd2ac (patch) | |
tree | a5ac57653b20eb6cc274c7c444e79ec91cd624d1 | |
parent | 76becac003bdfe2c3bcf37f6f5f6024d1aac7d73 (diff) |
Add event ID index on current state table (helps performance) (#1649)
-rw-r--r-- | syncapi/storage/postgres/current_room_state_table.go | 2 | ||||
-rw-r--r-- | syncapi/storage/sqlite3/current_room_state_table.go | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/syncapi/storage/postgres/current_room_state_table.go b/syncapi/storage/postgres/current_room_state_table.go index 554163e5..77e1e363 100644 --- a/syncapi/storage/postgres/current_room_state_table.go +++ b/syncapi/storage/postgres/current_room_state_table.go @@ -58,6 +58,8 @@ CREATE TABLE IF NOT EXISTS syncapi_current_room_state ( CREATE UNIQUE INDEX IF NOT EXISTS syncapi_event_id_idx ON syncapi_current_room_state(event_id, room_id, type, sender, contains_url); -- for querying membership states of users CREATE INDEX IF NOT EXISTS syncapi_membership_idx ON syncapi_current_room_state(type, state_key, membership) WHERE membership IS NOT NULL AND membership != 'leave'; +-- for querying state by event IDs +CREATE UNIQUE INDEX IF NOT EXISTS syncapi_current_room_state_eventid_idx ON syncapi_current_room_state(event_id); ` const upsertRoomStateSQL = "" + diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go index f16a6612..ac659057 100644 --- a/syncapi/storage/sqlite3/current_room_state_table.go +++ b/syncapi/storage/sqlite3/current_room_state_table.go @@ -46,6 +46,8 @@ CREATE TABLE IF NOT EXISTS syncapi_current_room_state ( CREATE UNIQUE INDEX IF NOT EXISTS syncapi_event_id_idx ON syncapi_current_room_state(event_id, room_id, type, sender, contains_url); -- for querying membership states of users -- CREATE INDEX IF NOT EXISTS syncapi_membership_idx ON syncapi_current_room_state(type, state_key, membership) WHERE membership IS NOT NULL AND membership != 'leave'; +-- for querying state by event IDs +CREATE UNIQUE INDEX IF NOT EXISTS syncapi_current_room_state_eventid_idx ON syncapi_current_room_state(event_id); ` const upsertRoomStateSQL = "" + |