summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--changelog.d/15731.misc1
-rw-r--r--synapse/storage/databases/main/roommember.py7
2 files changed, 4 insertions, 4 deletions
diff --git a/changelog.d/15731.misc b/changelog.d/15731.misc
new file mode 100644
index 0000000000..906bc26962
--- /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`).
diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py
index ae9c201b87..1b8ec67f54 100644
--- a/synapse/storage/databases/main/roommember.py
+++ b/synapse/storage/databases/main/roommember.py
@@ -927,11 +927,10 @@ class RoomMemberWorkerStore(EventsWorkerStore, CacheInvalidationWorkerStore):
             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
         """