Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Reduce to-device queries for /sync. #12163

Merged
merged 3 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/12163.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reduce number of DB queries made during processing of `/sync`.
3 changes: 3 additions & 0 deletions synapse/storage/databases/main/deviceinbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@ async def _get_device_messages(
# 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.
Expand Down