Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Simplify query to _count_known_servers() for the synapse_federation_known_servers metric #15735

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/15735.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify query to `_count_known_servers()` for the `synapse_federation_known_servers` metric.
8 changes: 4 additions & 4 deletions synapse/storage/databases/main/roommember.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ def _transact(txn: LoggingTransaction) -> int:
query = """
SELECT COUNT(DISTINCT substr(out.user_id, pos+1))
FROM (
SELECT rm.user_id as user_id, instr(rm.user_id, ':')
AS pos FROM room_memberships as rm
INNER JOIN current_state_events as c ON rm.event_id = c.event_id
WHERE c.type = 'm.room.member'
Comment on lines -136 to -137
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If #15734 (comment) is valid, then I think this simplification is also valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a valid change, see #15734 (comment)

SELECT
user_id AS user_id,
instr(user_id, ':') AS pos
FROM room_memberships
) as out
"""
else:
Expand Down