From 9f5bf49ac750fdf8a5e60a7a9d7b8cc99ee9bb51 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 3 Apr 2025 16:17:59 -0700 Subject: [PATCH] sqldb/sqlite: enable incremental auto_vacuum on DB creation --- sqldb/sqlite.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sqldb/sqlite.go b/sqldb/sqlite.go index e6a291a17..a542a9b63 100644 --- a/sqldb/sqlite.go +++ b/sqldb/sqlite.go @@ -40,6 +40,12 @@ var ( _ DB = (*SqliteStore)(nil) ) +// pragmaOption holds a key-value pair for a SQLite pragma setting. +type pragmaOption struct { + name string + value string +} + // SqliteStore is a database store implementation that uses a sqlite backend. type SqliteStore struct { cfg *SqliteConfig @@ -53,10 +59,7 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) { // The set of pragma options are accepted using query options. For now // we only want to ensure that foreign key constraints are properly // enforced. - pragmaOptions := []struct { - name string - value string - }{ + pragmaOptions := []pragmaOption{ { name: "foreign_keys", value: "on", @@ -84,6 +87,10 @@ func NewSqliteStore(cfg *SqliteConfig, dbPath string) (*SqliteStore, error) { name: "fullfsync", value: "true", }, + { + name: "auto_vacuum", + value: "incremental", + }, } sqliteOptions := make(url.Values) for _, option := range pragmaOptions {