Bound find_next_generated_user_id DB query.

We can easily bound the set of user IDs we pull out of the DB, so lets
do that.
This commit is contained in:
Erik Johnston 2019-10-02 11:21:52 +01:00
parent ecd254bc49
commit d69fd53f74

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+):")