Cookbook recipe

Diagnose wraparound-driven aggressive autovacuum

Applies to PostgreSQL 13–17 Last reviewed May 2026 Grounded in source
Estimated investigation4 min

Scenario

Autovacuum suddenly scans huge old tables even though they barely changed, hammering I/O. This is anti-wraparound (aggressive) vacuum doing its job. Diagnose it See which tables are due for freezing: SELECT relname, age(relfrozenxid) AS xid_age FROM…

Investigation Path

Autovacuum suddenly scans huge old tables even though they barely changed, hammering I/O. This is anti-wraparound (aggressive) vacuum doing its job.

Diagnose it

See which tables are due for freezing:

SELECT relname, age(relfrozenxid) AS xid_age
FROM pg_class WHERE relkind='r'
ORDER BY xid_age DESC LIMIT 15;

Why it happens

When a table’s age(relfrozenxid) crosses autovacuum_freeze_max_age, PostgreSQL forces an aggressive vacuum that scans all unfrozen pages to freeze old XIDs — preventing wraparound. It cannot be skipped and ignores the cost-delay nap as needed.

This is a Pro lesson

Get every Learning Pathway and cookbook recipe — grounded in PostgreSQL source code, with diagnostics, fixes, and prevention for each topic.

Continue this lesson to learn:

  • How to fix it
  • Prevent it next time
  • Related & next steps
  • All 36 Learning Pathway lessons
  • 170+ cookbook recipes
  • Source-grounded diagnostics & fixes

Secure checkout Cancel anytime Source-grounded

Career Impact

This scenario builds production judgment and operational confidence under pressure.

Open Career Dashboard →

Keep going

Related & next steps

Was this helpful?

← All cookbook recipes