diff options
author | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-09 13:50:50 +0100 |
---|---|---|
committer | Neil Alexander <neilalexander@users.noreply.github.com> | 2022-09-09 13:50:50 +0100 |
commit | 6ee758df63fc2c5f107954e9b436d361cc147741 (patch) | |
tree | fb974647eea4faa76f68bb7e612ca149cf6a8c81 /syncapi | |
parent | e1bc4f6a1ed446380408fad902ed1e314bcd99c5 (diff) |
Optimise shared users query in Synx API slightly by removing a potential sort
Diffstat (limited to 'syncapi')
-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, 2 insertions, 2 deletions
diff --git a/syncapi/storage/postgres/current_room_state_table.go b/syncapi/storage/postgres/current_room_state_table.go index 58f40451..37294e46 100644 --- a/syncapi/storage/postgres/current_room_state_table.go +++ b/syncapi/storage/postgres/current_room_state_table.go @@ -111,7 +111,7 @@ const selectEventsWithEventIDsSQL = "" + const selectSharedUsersSQL = "" + "SELECT state_key FROM syncapi_current_room_state WHERE room_id = ANY(" + - " SELECT room_id FROM syncapi_current_room_state WHERE state_key = $1 AND membership='join'" + + " SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE state_key = $1 AND membership='join'" + ") AND state_key = ANY($2) AND membership IN ('join', 'invite');" type currentRoomStateStatements struct { diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go index 3a10b232..2765c14b 100644 --- a/syncapi/storage/sqlite3/current_room_state_table.go +++ b/syncapi/storage/sqlite3/current_room_state_table.go @@ -95,7 +95,7 @@ const selectEventsWithEventIDsSQL = "" + const selectSharedUsersSQL = "" + "SELECT state_key FROM syncapi_current_room_state WHERE room_id IN(" + - " SELECT room_id FROM syncapi_current_room_state WHERE state_key = $1 AND membership='join'" + + " SELECT DISTINCT room_id FROM syncapi_current_room_state WHERE state_key = $1 AND membership='join'" + ") AND state_key IN ($2) AND membership IN ('join', 'invite');" type currentRoomStateStatements struct { |