diff options
author | Erik Johnston <erik@matrix.org> | 2019-10-10 16:41:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-10 16:41:36 +0100 |
commit | 83d86106a8637dc1d9ffd44840c057b10aa87287 (patch) | |
tree | bc62be567a509f6a273b4f3ded979065ca8e5cbb /synapse/storage/search.py | |
parent | Merge pull request #6186 from matrix-org/erikj/disable_sql_bytes (diff) | |
parent | Fix SQLite take 2 (diff) | |
download | synapse-83d86106a8637dc1d9ffd44840c057b10aa87287.tar.xz |
Merge pull request #6156 from matrix-org/erikj/postgres_any
Use Postgres ANY for selecting many values.
Diffstat (limited to 'synapse/storage/search.py')
-rw-r--r-- | synapse/storage/search.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/synapse/storage/search.py b/synapse/storage/search.py index 6ba4190f1a..7695bf09fc 100644 --- a/synapse/storage/search.py +++ b/synapse/storage/search.py @@ -24,6 +24,7 @@ from canonicaljson import json from twisted.internet import defer from synapse.api.errors import SynapseError +from synapse.storage._base import make_in_list_sql_clause from synapse.storage.engines import PostgresEngine, Sqlite3Engine from .background_updates import BackgroundUpdateStore @@ -385,8 +386,10 @@ class SearchStore(SearchBackgroundUpdateStore): # Make sure we don't explode because the person is in too many rooms. # We filter the results below regardless. if len(room_ids) < 500: - clauses.append("room_id IN (%s)" % (",".join(["?"] * len(room_ids)),)) - args.extend(room_ids) + clause, args = make_in_list_sql_clause( + self.database_engine, "room_id", room_ids + ) + clauses = [clause] local_clauses = [] for key in keys: @@ -492,8 +495,10 @@ class SearchStore(SearchBackgroundUpdateStore): # Make sure we don't explode because the person is in too many rooms. # We filter the results below regardless. if len(room_ids) < 500: - clauses.append("room_id IN (%s)" % (",".join(["?"] * len(room_ids)),)) - args.extend(room_ids) + clause, args = make_in_list_sql_clause( + self.database_engine, "room_id", room_ids + ) + clauses = [clause] local_clauses = [] for key in keys: |