From 5c383da5eccddf4ad0b4b7ddd8cb0035b6e49216 Mon Sep 17 00:00:00 2001 From: DingDongSoLong4 <99329275+DingDongSoLong4@users.noreply.github.com> Date: Wed, 14 Sep 2022 01:15:36 +0200 Subject: [PATCH] Optimize database after migration (#2904) --- pkg/sqlite/database.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/sqlite/database.go b/pkg/sqlite/database.go index 1c21d5415..d73abb977 100644 --- a/pkg/sqlite/database.go +++ b/pkg/sqlite/database.go @@ -346,8 +346,12 @@ func (db *Database) RunMigrations() error { return fmt.Errorf("re-initializing the database: %w", err) } - // run a vacuum on the database - logger.Info("Performing vacuum on database") + // optimize database after migration + logger.Info("Optimizing database") + _, err = db.db.Exec("ANALYZE") + if err != nil { + logger.Warnf("error while performing post-migration optimization: %v", err) + } _, err = db.db.Exec("VACUUM") if err != nil { logger.Warnf("error while performing post-migration vacuum: %v", err)