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

Commit

Permalink
Merge pull request #6148 from matrix-org/erikj/find_next_generated
Browse files Browse the repository at this point in the history
  • Loading branch information
anoadragon453 committed Feb 26, 2020
2 parents 9f7acf6 + 5d8ffdf commit dc68d85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions changelog.d/6148.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improve performance of `find_next_generated_user_id` DB query.
4 changes: 3 additions & 1 deletion synapse/storage/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,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

0 comments on commit dc68d85

Please sign in to comment.