mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-09 19:07:12 +02:00
feat(pglite): vacuum as well as analyze after a scan
The single-user backend has no autovacuum, and each scan leaves a dead version of every updated row (all 29,602 library_artist rows per stats refresh). VACUUM (ANALYZE) takes 9.7 s on the 97k-track library.
This commit is contained in:
parent
943beae278
commit
bf3af008d6
1 changed files with 4 additions and 2 deletions
|
|
@ -133,8 +133,10 @@ func optimizeAt(ctx context.Context, db *sql.DB, now time.Time) error {
|
|||
if err := markOptimizePending(ctx, db); err != nil {
|
||||
return recordAnalyzeError(ctx, db, now, fmt.Errorf("marking ANALYZE pending: %w", err))
|
||||
}
|
||||
log.Debug(ctx, "Refreshing query planner statistics")
|
||||
_, err := db.ExecContext(ctx, "ANALYZE")
|
||||
// VACUUM too: the single-user backend has no autovacuum, and every scan leaves a dead
|
||||
// version of each updated row behind.
|
||||
log.Debug(ctx, "Vacuuming and refreshing query planner statistics")
|
||||
_, err := db.ExecContext(ctx, "VACUUM (ANALYZE)")
|
||||
if err != nil {
|
||||
return recordAnalyzeError(ctx, db, now, fmt.Errorf("running ANALYZE: %w", err))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue