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.
This commit is contained in:
SmallCoccinelle 2021-09-21 03:38:56 +02:00 committed by GitHub
parent 87709fd018
commit b7c229dc70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"
}