diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-06-11 18:22:50 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2015-06-11 18:22:50 +0000 |
commit | 0ad535a3a4929857b2aef24284d9e6354e9ce3ba (patch) | |
tree | 1692a5bc6ac8f5f6067e190e0af0cbec6de213b7 | |
parent | 26d7899ee16830b0ae5058fcd664fc69df514ff1 (diff) | |
download | morph-cache-server-0ad535a3a4929857b2aef24284d9e6354e9ce3ba.tar.gz |
Tweak SQLite parameters to try and make writes faster
Currently they are very slow! Batching writes is going to be needed
at some point, too.
-rw-r--r-- | morphcacheserver/artifact_database.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/morphcacheserver/artifact_database.py b/morphcacheserver/artifact_database.py index 0da46c4..f893b49 100644 --- a/morphcacheserver/artifact_database.py +++ b/morphcacheserver/artifact_database.py @@ -37,6 +37,18 @@ class ArtifactDatabase(object): def __init__(self, database_file): self.db, self.paramstyle = yoyo.connections.connect( 'sqlite:///' + database_file) + + # SQLite is by default very slow to write due to fsync() calls. These + # settings make it faster, but at a slightly increased risk of data + # loss. + # + # See: + # - https://sqlite.org/pragma.html#pragma_synchronous + # - https://sqlite.org/pragma.html#pragma_journal_mode + cursor = self.db.cursor() + cursor.execute('PRAGMA journal_mode=WAL;') + cursor.execute('PRAGMA synchronous=NORMAL;') + self.apply_migrations(self.migrations_dir()) def migrations_dir(self): |