From db2e350e294d7b696b47822e6e857f482af2f6f1 Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Fri, 24 Oct 2014 19:04:16 +0100 Subject: [PATCH] Wrap preparing the database in a transaction. Otherwise it will take many seconds to complete because sqlite will create a transaction per statement --- synapse/storage/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/synapse/storage/__init__.py b/synapse/storage/__init__.py index 3aa6345a7..4e9291fdf 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)