Christophe Pettus: All Your GUCs in a Row: Autovacuum_work_mem

Christophe Pettus: All Your GUCs in a Row: Autovacuum_work_mem

Planet PostgreSQL
Planet PostgreSQLMay 11, 2026

Why It Matters

Efficient autovacuum memory management directly impacts database performance and resource allocation, preventing costly multi‑pass index scans that can stall production workloads. The PG 17 redesign simplifies tuning and frees memory for foreground operations, delivering tangible operational savings.

Key Takeaways

  • PG 17 removes 1 GB TID list cap with adaptive radix tree
  • autovacuum_work_mem defaults to -1, inheriting maintenance_work_mem
  • Set autovacuum_work_mem to 1 GB on PG 16 for large tables
  • Raise autovacuum_max_workers, then lower autovacuum_work_mem to limit total memory
  • Monitor index_vacuum_count >1 to detect multi‑pass vacuum

Pulse Analysis

The shift to an adaptive radix‑tree TIDStore in PostgreSQL 17 marks a fundamental change in how autovacuum manages dead tuple identifiers. By discarding the 1 GB flat‑array ceiling, the new implementation can store far more TIDs within the same memory budget, dramatically reducing the likelihood of multi‑pass index clean‑ups. This architectural improvement means that most workloads now complete vacuum operations in a single pass, cutting vacuum time from hours to minutes on heavily indexed tables.

For database administrators, the practical implication is a simplification of memory tuning. The autovacuum_work_mem parameter, which previously required careful sizing to avoid wasted memory on PG 16 and earlier, can safely remain at its default (-1) on PG 17+. Autovacuum workers will inherit the maintenance_work_mem setting, and the radix‑tree engine will efficiently use the allocated memory. However, when scaling autovacuum_max_workers beyond the default three, it may still be prudent to set a lower autovacuum_work_mem to keep total background memory consumption in check, preserving resources for foreground tasks like manual VACUUM, CREATE INDEX, or REINDEX.

Monitoring remains essential. The pg_stat_progress_vacuum view now provides an index_vacuum_count metric that flags when a vacuum has entered a multi‑pass cycle. While such events are rare on PostgreSQL 17, they serve as a valuable diagnostic signal for edge cases or mis‑configurations. On older releases, administrators should continue to cap autovacuum_work_mem at 1 GB for large, heavily updated tables and rely on per‑table vacuum_scale_factor adjustments to control dead‑tuple accumulation. This balanced approach ensures optimal performance across PostgreSQL versions.

Christophe Pettus: All Your GUCs in a Row: autovacuum_work_mem

Comments

Want to join the conversation?

Loading comments...