summary refs log tree commit diff
path: root/synapse/storage/events.py
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-05-05 18:30:35 +0100
committerMark Haines <mjark@negativecurvature.net>2015-05-05 18:30:35 +0100
commitecb26beda5582df286d5d21a91013b9cdb730e07 (patch)
treeadffd54138cb4d537edb45f2d715e26a391edb76 /synapse/storage/events.py
parentUse buffer(...) when inserting into bytea column (diff)
parentAnd use buffer(...) there as well (diff)
downloadsynapse-ecb26beda5582df286d5d21a91013b9cdb730e07.tar.xz
Merge pull request #137 from matrix-org/erikj/executemany
executemany support
Diffstat (limited to 'synapse/storage/events.py')
-rw-r--r--synapse/storage/events.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/synapse/storage/events.py b/synapse/storage/events.py
index 17f9d27289..ba180da56d 100644
--- a/synapse/storage/events.py
+++ b/synapse/storage/events.py
@@ -129,7 +129,7 @@ class EventsStore(SQLBaseStore):
                         "room_id": s.room_id,
                         "type": s.type,
                         "state_key": s.state_key,
-                    },
+                    }
                 )
 
         if event.is_state() and is_new_state:
@@ -306,16 +306,18 @@ class EventsStore(SQLBaseStore):
                     hash_bytes
                 )
 
-        for auth_id, _ in event.auth_events:
-            self._simple_insert_txn(
-                txn,
-                table="event_auth",
-                values={
+        self._simple_insert_many_txn(
+            txn,
+            table="event_auth",
+            values=[
+                {
                     "event_id": event.event_id,
                     "room_id": event.room_id,
                     "auth_id": auth_id,
-                },
-            )
+                }
+                for auth_id, _ in event.auth_events
+            ],
+        )
 
         (ref_alg, ref_hash_bytes) = compute_event_reference_hash(event)
         self._store_event_reference_hash_txn(
@@ -340,17 +342,19 @@ class EventsStore(SQLBaseStore):
                 vals,
             )
 
-            for e_id, h in event.prev_state:
-                self._simple_insert_txn(
-                    txn,
-                    table="event_edges",
-                    values={
+            self._simple_insert_many_txn(
+                txn,
+                table="event_edges",
+                values=[
+                    {
                         "event_id": event.event_id,
                         "prev_event_id": e_id,
                         "room_id": event.room_id,
                         "is_state": True,
-                    },
-                )
+                    }
+                    for e_id, h in event.prev_state
+                ],
+            )
 
             if is_new_state and not context.rejected:
                 self._simple_upsert_txn(