From a23749efbacdf37251faa6662eec08f5287b024a Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 6 Jun 2023 15:12:13 -0500 Subject: [PATCH 1/2] No need for the extra join since membership is built-in to `current_state_events` `current_state_events` was added in https://github.com/matrix-org/synapse/pull/5706 and https://github.com/matrix-org/synapse/pull/13745 --- synapse/storage/databases/main/roommember.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py index ae9c201b87e8..1b8ec67f5487 100644 --- a/synapse/storage/databases/main/roommember.py +++ b/synapse/storage/databases/main/roommember.py @@ -927,11 +927,10 @@ async def _check_host_room_membership( raise Exception("Invalid host name") sql = """ - SELECT state_key FROM current_state_events AS c - INNER JOIN room_memberships AS m USING (event_id) - WHERE m.membership = ? + SELECT state_key FROM current_state_events + WHERE membership = ? AND type = 'm.room.member' - AND c.room_id = ? + AND room_id = ? AND state_key LIKE ? LIMIT 1 """ From 81027ea60ca7f6e64395ea3b0bae995b761e554c Mon Sep 17 00:00:00 2001 From: Eric Eastwood Date: Tue, 6 Jun 2023 15:28:55 -0500 Subject: [PATCH 2/2] Add changelog --- changelog.d/15731.misc | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/15731.misc diff --git a/changelog.d/15731.misc b/changelog.d/15731.misc new file mode 100644 index 000000000000..906bc2696254 --- /dev/null +++ b/changelog.d/15731.misc @@ -0,0 +1 @@ +Remove redundant table join with `room_memberships` when doing a `is_host_joined()`/`is_host_invited()` call (`membership` is already part of the `current_state_events`).