diff options
author | Mark Haines <mark.haines@matrix.org> | 2014-10-24 19:04:16 +0100 |
---|---|---|
committer | Mark Haines <mark.haines@matrix.org> | 2014-10-24 19:04:26 +0100 |
commit | db2e350e294d7b696b47822e6e857f482af2f6f1 (patch) | |
tree | cf9e9da0e3e0d5011fb6b130ff96f16bab624caa /synapse/storage/__init__.py | |
parent | switch from the deprecated msg.content.prev to msg.prev_content.membership, a... (diff) | |
download | synapse-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__.py | 7 |
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) |