diff --git a/synapse/storage/databases/main/relations.py b/synapse/storage/databases/main/relations.py index c54134eb1e64..2275a583508b 100644 --- a/synapse/storage/databases/main/relations.py +++ b/synapse/storage/databases/main/relations.py @@ -859,7 +859,7 @@ async def get_threads( relation_type = '{RelationTypes.THREAD}' {pagination_clause} GROUP BY relates_to_id - ORDER BY topological_ordering DESC, stream_ordering DESC + ORDER BY MAX(topological_ordering) DESC, MAX(stream_ordering) DESC LIMIT ? """