From 8b2747e4d7b31595f6d1e929617e11322e55c709 Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Mon, 26 Jul 2021 17:33:32 -0700 Subject: [PATCH] Add some sqlite optimizations --- core/data/data.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/data/data.go b/core/data/data.go index 1bed7b28d..7ca010800 100644 --- a/core/data/data.go +++ b/core/data/data.go @@ -45,10 +45,16 @@ func SetupPersistence(file string) error { } } - db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?_cache_size=10000", file)) + db, err := sql.Open("sqlite3", fmt.Sprintf("file:%s?_cache_size=10000&cache=shared&_journal_mode=WAL", file)) db.SetMaxOpenConns(1) _db = db + // Some SQLite optimizations + _, _ = db.Exec("pragma journal_mode = WAL") + _, _ = db.Exec("pragma synchronous = normal") + _, _ = db.Exec("pragma temp_store = memory") + _, _ = db.Exec("pragma wal_checkpoint(full)") + createWebhooksTable() createUsersTable(db)