Merge pull request #6148 from matrix-org/erikj/find_next_generated

Bound find_next_generated_user_id DB query.
pull/6160/head
Erik Johnston 2019-10-02 16:09:02 +01:00 committed by GitHub
commit 5d8ffdfe61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

1
changelog.d/6148.misc Normal file
View File

@ -0,0 +1 @@
Improve performance of `find_next_generated_user_id` DB query.

View File

@ -493,7 +493,9 @@ class RegistrationWorkerStore(SQLBaseStore):
"""
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+):")