Optimize database after migration (#2904)

This commit is contained in:
DingDongSoLong4 2022-09-14 01:15:36 +02:00 committed by GitHub
parent cfc8222b9a
commit 5c383da5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -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)