0PricingLogin
SQL Academy · Lesson

VACUUM, autovacuum, vacuum_cost_delay

Tune autovacuum thresholds, vacuum_cost_delay, and parallel VACUUM for big tables.

Three VACUUM Modes

  • VACUUM (lazy) — reclaim dead rows, update free space map, no exclusive lock
  • VACUUM FULL — rewrite the table; exclusive lock; releases disk back to OS
  • VACUUM ANALYZE — vacuum + refresh planner statistics in one go

Running VACUUM Manually

Sometimes useful even with autovacuum:

VACUUM (VERBOSE) orders;
VACUUM (VERBOSE, ANALYZE) orders;
VACUUM (PARALLEL 4) orders;       -- parallel index cleanup (PG 13+)

All lessons in this course

  1. MVCC and Bloat Causes
  2. VACUUM, autovacuum, vacuum_cost_delay
  3. ANALYZE and pg_statistic
  4. Index-Only Scans and Visibility Map
← Back to SQL Academy