Add Analyse on db startup

Entire-Checkpoint: ea70a955214d
This commit is contained in:
2026-03-11 05:28:52 +01:00
parent f8831e7040
commit eba3995610
6 changed files with 265 additions and 11 deletions

View File

@@ -48,6 +48,14 @@ func setupSqlite(db *sql.DB) error {
}
}
// Update query planner statistics so SQLite picks optimal indexes.
// Without this, SQLite guesses row distributions and often chooses wrong
// indexes for queries with IN clauses + ORDER BY, causing full table sorts
// in temp B-trees instead of using covering indexes.
if _, err := db.Exec("ANALYZE"); err != nil {
cclog.Warnf("Failed to run ANALYZE: %v", err)
}
return nil
}