This repository has been archived by the owner on Apr 26, 2024. It is now read-only.
Slow query performance(?) in list users API due to naive join to profiles table #14254
Labels
A-Admin-API
A-Database
DB stuff like queries, migrations, new/remove columns, indexes, unexpected entries in the db
A-Performance
Performance, both client-facing and admin-facing
O-Uncommon
Most users are unlikely to come across this or unexpected workflow
S-Minor
Blocks non-critical functionality, workarounds exist.
T-Enhancement
New features, changes in functionality, improvements in performance, or user-facing enhancements.
Noticed in https://github.com/matrix-org/synapse/pull/14205/files#r1001678137
The join condition is
users.name = '@' || profiles.user_id || ':' || 'matrix.example.com'
. This isn't of the formprofiles.user_id = X
, and so postgres can't use the index onprofiles.user_id
to to lookup a profiles row.I think the condition
might work here. It seems to be standard sql (though I haven't been able to find a reference for exactly how that regex is matched). In my testing, the proposed query performs/is planned much better:
Compared to the old one:
The text was updated successfully, but these errors were encountered: