Merge branch 'develop' of github.com:matrix-org/synapse into matrix-org-hotfixes
commit
23bb2713d2
|
@ -0,0 +1 @@
|
||||||
|
Improve performance of `find_next_generated_user_id` DB query.
|
|
@ -0,0 +1 @@
|
||||||
|
Improve performance of the public room list directory.
|
|
@ -0,0 +1 @@
|
||||||
|
Improve performance of the public room list directory.
|
|
@ -493,7 +493,9 @@ class RegistrationWorkerStore(SQLBaseStore):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _find_next_generated_user_id(txn):
|
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+):")
|
regex = re.compile(r"^@(\d+):")
|
||||||
|
|
||||||
|
|
|
@ -150,6 +150,24 @@ class RoomWorkerStore(SQLBaseStore):
|
||||||
where_clauses = []
|
where_clauses = []
|
||||||
query_args = []
|
query_args = []
|
||||||
|
|
||||||
|
if network_tuple:
|
||||||
|
if network_tuple.appservice_id:
|
||||||
|
published_sql = """
|
||||||
|
SELECT room_id from appservice_room_list
|
||||||
|
WHERE appservice_id = ? AND network_id = ?
|
||||||
|
"""
|
||||||
|
query_args.append(network_tuple.appservice_id)
|
||||||
|
query_args.append(network_tuple.network_id)
|
||||||
|
else:
|
||||||
|
published_sql = """
|
||||||
|
SELECT room_id FROM rooms WHERE is_public
|
||||||
|
"""
|
||||||
|
else:
|
||||||
|
published_sql = """
|
||||||
|
SELECT room_id FROM rooms WHERE is_public
|
||||||
|
UNION SELECT room_id from appservice_room_list
|
||||||
|
"""
|
||||||
|
|
||||||
# Work out the bounds if we're given them, these bounds look slightly
|
# Work out the bounds if we're given them, these bounds look slightly
|
||||||
# odd, but are designed to help query planner use indices by pulling
|
# odd, but are designed to help query planner use indices by pulling
|
||||||
# out a common bound.
|
# out a common bound.
|
||||||
|
@ -174,6 +192,9 @@ class RoomWorkerStore(SQLBaseStore):
|
||||||
|
|
||||||
query_args += [last_joined_members, last_joined_members, last_room_id]
|
query_args += [last_joined_members, last_joined_members, last_room_id]
|
||||||
|
|
||||||
|
if ignore_non_federatable:
|
||||||
|
where_clauses.append("is_federatable")
|
||||||
|
|
||||||
if search_filter and search_filter.get("generic_search_term", None):
|
if search_filter and search_filter.get("generic_search_term", None):
|
||||||
search_term = "%" + search_filter["generic_search_term"] + "%"
|
search_term = "%" + search_filter["generic_search_term"] + "%"
|
||||||
|
|
||||||
|
@ -188,24 +209,6 @@ class RoomWorkerStore(SQLBaseStore):
|
||||||
)
|
)
|
||||||
query_args += [search_term, search_term, search_term]
|
query_args += [search_term, search_term, search_term]
|
||||||
|
|
||||||
if network_tuple:
|
|
||||||
if network_tuple.appservice_id:
|
|
||||||
published_sql = """
|
|
||||||
SELECT room_id from appservice_room_list
|
|
||||||
WHERE appservice_id = ? AND network_id = ?
|
|
||||||
"""
|
|
||||||
query_args.append(network_tuple.appservice_id)
|
|
||||||
query_args.append(network_tuple.network_id)
|
|
||||||
else:
|
|
||||||
published_sql = """
|
|
||||||
SELECT room_id FROM rooms WHERE is_public
|
|
||||||
"""
|
|
||||||
else:
|
|
||||||
published_sql = """
|
|
||||||
SELECT room_id FROM rooms WHERE is_public
|
|
||||||
UNION SELECT room_id from appservice_room_list
|
|
||||||
"""
|
|
||||||
|
|
||||||
where_clause = ""
|
where_clause = ""
|
||||||
if where_clauses:
|
if where_clauses:
|
||||||
where_clause = " AND " + " AND ".join(where_clauses)
|
where_clause = " AND " + " AND ".join(where_clauses)
|
||||||
|
|
Loading…
Reference in New Issue