From b7c229dc701023e567050b2fbb5080fafb23ec56 Mon Sep 17 00:00:00 2001 From: SmallCoccinelle <89733524+SmallCoccinelle@users.noreply.github.com> Date: Tue, 21 Sep 2021 03:38:56 +0200 Subject: [PATCH] Set NORMAL sync on sqlite3 (#1684) NORMAL sync is safe when using WAL journaliing. It cuts the amount of sync calls to the disk, resulting in faster write operation. On power loss, the database will perhaps lose some ongoing commits, but that is all. The expectation is that if the database lives on the same disk as the stash, this could help performance quite a bit under heavier operation. --- pkg/database/database.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/database/database.go b/pkg/database/database.go index b1658e00f..f2aa58734 100644 --- a/pkg/database/database.go +++ b/pkg/database/database.go @@ -98,7 +98,7 @@ func Close() error { func open(databasePath string, disableForeignKeys bool) *sqlx.DB { // https://github.com/mattn/go-sqlite3 - url := "file:" + databasePath + "?_journal=WAL" + url := "file:" + databasePath + "?_journal=WAL&_sync=NORMAL" if !disableForeignKeys { url += "&_fk=true" }