Context
The howto at docs/postgres-howtos/database-administration/maintenance/autovacuum-queue-and-progress.md covers autovacuum queue depth and live progress monitoring. A review against the Cybertec autovacuum monitoring article and the postgres-ai SQL style guide surfaced a number of gaps and improvements.
Correctness / coverage
Query quality
Adjacent diagnostics
Tuning guidance / prose
Output / UX
References
Context
The howto at
docs/postgres-howtos/database-administration/maintenance/autovacuum-queue-and-progress.mdcovers autovacuum queue depth and live progress monitoring. A review against the Cybertec autovacuum monitoring article and the postgres-ai SQL style guide surfaced a number of gaps and improvements.Correctness / coverage
autovacuum_vacuum_max_thresholdto the trigger formula — effective threshold isleast(max_threshold, threshold + scale_factor * reltuples); without it the query overstates urgency on large tables under PG 18autovacuum_vacuum_insert_threshold/autovacuum_vacuum_insert_scale_factor(PG 13+) — insert-mostly tables are invisible to the current queryautovacuum_enabledlabel —case when autovacuum_enabled then 'DISABLED' else 'enabled' endis backwardsage(relfrozenxid)vs.autovacuum_freeze_max_ageandmxid_age(relminmxid)vs.autovacuum_multixact_freeze_max_age, surfacewraparound_urgencyand per-table overridestrigger_reasoncolumn — {dead_tuples, inserts, freeze, multixact, in_progress} so each queue row says why it qualifiesQuery quality
LATERAL unnest(reloptions) + FILTER— shorter, faster, easier to extendvacuum_urgency = n_dead_tup / effective_thresholdratio and order by it, replacing the current boolean in/out-of-queue approachcurrent_setting('autovacuum_vacuum_max_threshold', true)with'Infinity'::float8fallback for PG 13–17reltuples = -1(PG 14+ initial value for freshly created tables) — urgency is meaningless in that caseformat('%I.%I', nspname, relname)for therelationcolumn instead of string concatenationfull outer join— aleft join+ optional union handles the "another DB" edge case more clearlyAdjacent diagnostics
pg_stat_progress_analyzecompanion query (the "natural extension" already mentioned in the page)pg_visibility_map_summary— different signal from dead-tuple count, relevant for index-only scanslast_autoanalyze/n_mod_since_analyzealongsidelast_autovacuum[auto]vacuum_cost_limit,[auto]vacuum_cost_delay, page-cost paramsTuning guidance / prose
autovacuum_max_workersgloballyvacuum_buffer_usage_limit(PG 16+) when discussing "make workers run faster"how-to-monitor-xmin-horizon.mdas the natural next step when cleanup is blockedOutput / UX
0067_tables_to_be_autovacuumed_2.png)\watch-friendly variant for staring at an in-progress vacuumReferences
how-to-monitor-xmin-horizon.md