diff options
author | Erik Johnston <erik@matrix.org> | 2022-03-04 17:57:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-04 17:57:27 +0000 |
commit | 0752ab7a3621b90073f9332fbfdc8afe16a3be01 (patch) | |
tree | 84f4e4b57acf0e81daff5fc855e5fc7ea6aca692 | |
parent | Add type hints for `ObservableDeferred` attributes (#12159) (diff) | |
download | synapse-0752ab7a3621b90073f9332fbfdc8afe16a3be01.tar.xz |
Reduce to-device queries for /sync. (#12163)
-rw-r--r-- | changelog.d/12163.misc | 1 | ||||
-rw-r--r-- | synapse/storage/databases/main/deviceinbox.py | 3 |
2 files changed, 4 insertions, 0 deletions
diff --git a/changelog.d/12163.misc b/changelog.d/12163.misc new file mode 100644 index 0000000000..13de0895f5 --- /dev/null +++ b/changelog.d/12163.misc @@ -0,0 +1 @@ +Reduce number of DB queries made during processing of `/sync`. diff --git a/synapse/storage/databases/main/deviceinbox.py b/synapse/storage/databases/main/deviceinbox.py index 1392363de1..b4a1b041b1 100644 --- a/synapse/storage/databases/main/deviceinbox.py +++ b/synapse/storage/databases/main/deviceinbox.py @@ -298,6 +298,9 @@ class DeviceInboxWorkerStore(SQLBaseStore): # This user has new messages sent to them. Query messages for them user_ids_to_query.add(user_id) + if not user_ids_to_query: + return {}, to_stream_id + def get_device_messages_txn(txn: LoggingTransaction): # Build a query to select messages from any of the given devices that # are between the given stream id bounds. |