Set some PRAGMAs to optimize the history database.

Enable write-ahead-logging and reduce the synchronous level to NORMAL.
This should reduce the number of writes to disk and avoid some of the
hangs users are experiencing.

Resolves #3507.
Resolves #2930 (optimistically, reopen if not fixed).

See https://sqlite.org/pragma.html and https://www.sqlite.org/wal.html.
This commit is contained in:
Ryan Roden-Corrent 2018-01-20 15:49:52 -05:00
parent d62cb58f7d
commit 9d5beff937

View File

@ -115,6 +115,11 @@ def init(db_path):
raise SqliteError("Failed to open sqlite database at {}: {}"
.format(db_path, error.text()), error)
# Enable write-ahead-logging and reduce disk write frequency
# see https://sqlite.org/pragma.html and issues #2930 and #3507
Query("PRAGMA journal_mode=WAL").run()
Query("PRAGMA synchronous=NORMAL").run()
def close():
"""Close the SQL connection."""