summary refs log tree commit diff
path: root/synapse/storage/__init__.py
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2014-10-24 19:04:16 +0100
committerMark Haines <mark.haines@matrix.org>2014-10-24 19:04:26 +0100
commitdb2e350e294d7b696b47822e6e857f482af2f6f1 (patch)
treecf9e9da0e3e0d5011fb6b130ff96f16bab624caa /synapse/storage/__init__.py
parentswitch from the deprecated msg.content.prev to msg.prev_content.membership, a... (diff)
downloadsynapse-db2e350e294d7b696b47822e6e857f482af2f6f1.tar.xz
Wrap preparing the database in a transaction. Otherwise it will take many seconds to complete because sqlite will create a transaction per statement
Diffstat (limited to 'synapse/storage/__init__.py')
-rw-r--r--synapse/storage/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py
index 3aa6345a7f..4e9291fdff 100644
--- a/synapse/storage/__init__.py
+++ b/synapse/storage/__init__.py
@@ -452,10 +452,11 @@ def prepare_database(db_conn):
             db_conn.commit()
 
     else:
+        sql_script = "BEGIN TRANSACTION;"
         for sql_loc in SCHEMAS:
-            sql_script = read_schema(sql_loc)
-
-            c.executescript(sql_script)
+            sql_script += read_schema(sql_loc)
+        sql_script += "COMMIT TRANSACTION;"
+        c.executescript(sql_script)
         db_conn.commit()
         c.execute("PRAGMA user_version = %d" % SCHEMA_VERSION)