aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Alexander <neilalexander@users.noreply.github.com>2022-09-09 14:18:45 +0100
committerNeil Alexander <neilalexander@users.noreply.github.com>2022-09-09 14:18:45 +0100
commit955e69a3b7c3f3bb066cb47be6c49d4b03ff2891 (patch)
tree09fdb2d9c7034222ba8106ff19fd955c37cd557d
parent6ee758df63fc2c5f107954e9b436d361cc147741 (diff)
Optimise `SharedUsers` again by using complete composite index
-rw-r--r--syncapi/storage/postgres/current_room_state_table.go2
-rw-r--r--syncapi/storage/sqlite3/current_room_state_table.go2
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 37294e46..083d10b8 100644
--- a/syncapi/storage/postgres/current_room_state_table.go
+++ b/syncapi/storage/postgres/current_room_state_table.go
@@ -112,7 +112,7 @@ const selectEventsWithEventIDsSQL = "" +
const selectSharedUsersSQL = "" +
"SELECT state_key FROM syncapi_current_room_state WHERE room_id = ANY(" +
" 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');"
+ ") AND type = 'm.room.member' AND state_key = ANY($2) AND membership IN ('join', 'invite');"
type currentRoomStateStatements struct {
upsertRoomStateStmt *sql.Stmt
diff --git a/syncapi/storage/sqlite3/current_room_state_table.go b/syncapi/storage/sqlite3/current_room_state_table.go
index 2765c14b..b88c11f8 100644
--- a/syncapi/storage/sqlite3/current_room_state_table.go
+++ b/syncapi/storage/sqlite3/current_room_state_table.go
@@ -96,7 +96,7 @@ const selectEventsWithEventIDsSQL = "" +
const selectSharedUsersSQL = "" +
"SELECT state_key FROM syncapi_current_room_state WHERE room_id IN(" +
" 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');"
+ ") AND type = 'm.room.member' AND state_key IN ($2) AND membership IN ('join', 'invite');"
type currentRoomStateStatements struct {
db *sql.DB