2 files changed, 2 insertions, 1 deletions
diff --git a/changelog.d/13299.misc b/changelog.d/13299.misc
new file mode 100644
index 0000000000..a9d5566873
--- /dev/null
+++ b/changelog.d/13299.misc
@@ -0,0 +1 @@
+Improve performance of query `_get_subset_users_in_room_with_profiles`.
diff --git a/synapse/storage/databases/main/roommember.py b/synapse/storage/databases/main/roommember.py
index 105a518677..46ab6232d4 100644
--- a/synapse/storage/databases/main/roommember.py
+++ b/synapse/storage/databases/main/roommember.py
@@ -243,7 +243,7 @@ class RoomMemberWorkerStore(EventsWorkerStore):
txn: LoggingTransaction,
) -> Dict[str, ProfileInfo]:
clause, ids = make_in_list_sql_clause(
- self.database_engine, "m.user_id", user_ids
+ self.database_engine, "c.state_key", user_ids
)
sql = """
|