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/deviceinbox.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/deviceinbox.py')
-rw-r--r-- | synapse/storage/deviceinbox.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/synapse/storage/deviceinbox.py b/synapse/storage/deviceinbox.py index 70bc2bb2cc..f04aad0743 100644 --- a/synapse/storage/deviceinbox.py +++ b/synapse/storage/deviceinbox.py @@ -20,7 +20,7 @@ from canonicaljson import json from twisted.internet import defer from synapse.logging.opentracing import log_kv, set_tag, trace -from synapse.storage._base import SQLBaseStore +from synapse.storage._base import SQLBaseStore, make_in_list_sql_clause from synapse.storage.background_updates import BackgroundUpdateStore from synapse.util.caches.expiringcache import ExpiringCache @@ -378,15 +378,15 @@ class DeviceInboxStore(DeviceInboxWorkerStore, DeviceInboxBackgroundUpdateStore) else: if not devices: continue - sql = ( - "SELECT device_id FROM devices" - " WHERE user_id = ? AND device_id IN (" - + ",".join("?" * len(devices)) - + ")" + + clause, args = make_in_list_sql_clause( + txn.database_engine, "device_id", devices ) + sql = "SELECT device_id FROM devices WHERE user_id = ? AND " + clause + # TODO: Maybe this needs to be done in batches if there are # too many local devices for a given user. - txn.execute(sql, [user_id] + devices) + txn.execute(sql, [user_id] + list(args)) for row in txn: # Only insert into the local inbox if the device exists on # this server |