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

Bound find_next_generated_user_id DB query. #6148

Merged
merged 2 commits into from Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/6148.misc
@@ -0,0 +1 @@
Improve performance of `find_next_generated_user_id` DB query.
4 changes: 3 additions & 1 deletion synapse/storage/registration.py
Expand Up @@ -493,7 +493,9 @@ def find_next_generated_user_id_localpart(self):
"""

def _find_next_generated_user_id(txn):
txn.execute("SELECT name FROM users")
# We bound between '@1' and '@a' to avoid pulling the entire table
# out.
txn.execute("SELECT name FROM users WHERE '@1' <= name AND name < '@a'")

regex = re.compile(r"^@(\d+):")

Expand Down