diff options
author | Erik Johnston <erik@matrix.org> | 2024-07-10 16:04:07 +0100 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2024-07-10 16:04:07 +0100 |
commit | 44a326cd033eeeef0618b78ab56b33709bdd3170 (patch) | |
tree | 684763f9f9ddf88d78d1791387460065ffb73d75 | |
parent | Fixup (diff) | |
download | synapse-44a326cd033eeeef0618b78ab56b33709bdd3170.tar.xz |
Fixup
-rw-r--r-- | synapse/storage/databases/main/stream.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/synapse/storage/databases/main/stream.py b/synapse/storage/databases/main/stream.py index d6801accab..7a4b74e0a7 100644 --- a/synapse/storage/databases/main/stream.py +++ b/synapse/storage/databases/main/stream.py @@ -1224,14 +1224,16 @@ class StreamWorkerStore(EventsWorkerStore, SQLBaseStore): txn: LoggingTransaction, ) -> Dict[str, int]: sql = f""" - SELECT DISTINCT ON (room_id) room_id, stream_ordering FROM events - WHERE room_id = ? AND stream_ordering IS NOT NULL - ORDER BY room_id, stream_ordering DESC + SELECT MAX(stream_ordering) FROM events + WHERE room_id = ? """ txn.execute(sql, (room_id,)) - return {room_id: stream_ordering for room_id, stream_ordering in txn} + row = txn.fetchone() + if row: + return row[0] + return None return await self.db_pool.runInteraction( "get_rough_stream_ordering_for_room", get_rough_stream_ordering_for_room_txn |