From 9d5beff93731d6a57c1354f641344ed7bef44696 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Sat, 20 Jan 2018 15:49:52 -0500 Subject: [PATCH] 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. --- qutebrowser/misc/sql.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py index 00527e7fe..65a93a461 100644 --- a/qutebrowser/misc/sql.py +++ b/qutebrowser/misc/sql.py @@ -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."""