mirror of
https://github.com/navidrome/navidrome.git
synced 2026-10-18 07:30:29 +00: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
@ -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…
x
Reference in New Issue
Block a user