summary refs log tree commit diff
path: root/synapse/storage/state.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2018-10-29 14:01:11 +0000
committerErik Johnston <erik@matrix.org>2018-10-29 14:01:11 +0000
commitb2399f6281d7cd11e7762b683bdd5a4f0c24927e (patch)
tree24282fcfc68e6a7d23e18b4bdee15ec3d6e5d0ff /synapse/storage/state.py
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj/purge_stat... (diff)
downloadsynapse-b2399f6281d7cd11e7762b683bdd5a4f0c24927e.tar.xz
Make SQL a bit cleaner
Diffstat (limited to 'synapse/storage/state.py')
-rw-r--r--synapse/storage/state.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/synapse/storage/state.py b/synapse/storage/state.py
index 59a50a5df9..45afd42b3f 100644
--- a/synapse/storage/state.py
+++ b/synapse/storage/state.py
@@ -1272,14 +1272,13 @@ class StateGroupWorkerStore(EventsWorkerStore, SQLBaseStore):
 
             # Check if state groups are referenced
             sql = """
-                SELECT state_group, count(*) FROM event_to_state_groups
+                SELECT DISTINCT state_group FROM event_to_state_groups
                 LEFT JOIN events_to_purge AS ep USING (event_id)
                 WHERE state_group IN (%s) AND ep.event_id IS NULL
-                GROUP BY state_group
             """ % (",".join("?" for _ in current_search),)
             txn.execute(sql, list(current_search))
 
-            referenced = set(sg for sg, cnt in txn if cnt > 0)
+            referenced = set(sg for sg, in txn)
             referenced_groups |= referenced
 
             # We don't continue iterating up the state group graphs for state