summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-06-23 11:01:04 +0100
committerErik Johnston <erik@matrix.org>2015-06-23 11:01:04 +0100
commit6924852592e4e3737ccd050938abc266ae71bf18 (patch)
treee763096203ac11c095eef84cfc7655aacffc4274 /synapse
parentFix typo (diff)
downloadsynapse-6924852592e4e3737ccd050938abc266ae71bf18.tar.xz
Batch SELECTs in _get_auth_chain_ids_txn
Diffstat (limited to 'synapse')
-rw-r--r--synapse/storage/event_federation.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/synapse/storage/event_federation.py b/synapse/storage/event_federation.py
index 1ba073884b..ace7459538 100644
--- a/synapse/storage/event_federation.py
+++ b/synapse/storage/event_federation.py
@@ -49,14 +49,22 @@ class EventFederationStore(SQLBaseStore):
         results = set()
 
         base_sql = (
-            "SELECT auth_id FROM event_auth WHERE event_id = ?"
+            "SELECT auth_id FROM event_auth WHERE event_id IN (%s)"
         )
 
         front = set(event_ids)
         while front:
             new_front = set()
-            for f in front:
-                txn.execute(base_sql, (f,))
+            front_list = list(front)
+            chunks = [
+                front_list[x:x+100]
+                for x in xrange(0, len(front), 100)
+            ]
+            for chunk in chunks:
+                txn.execute(
+                    base_sql % (",".join(["?"] * len(chunk)),),
+                    chunk
+                )
                 new_front.update([r[0] for r in txn.fetchall()])
 
             new_front -= results