DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Vacuuming / Automatic Vacuuming

autovacuum_freeze_max_age

Age at which to autovacuum a table to prevent transaction ID wraparound.

  • Default: 200000000
  • Type: integer
  • Range: 100000 … 2000000000
  • Applies: Restart required

In plain words

Transaction IDs are 32-bit and wrap around after about 2 billion. To keep old rows readable forever, VACUUM must "freeze" them before that. When a table's oldest unfrozen XID is older than this age (200 million by default), autovacuum forces an aggressive vacuum of it, whatever its dead-row count.

For DBAs and operators

Checked against age(pg_class.relfrozenxid). The forced run shows up as autovacuum: VACUUM public.t (to prevent wraparound) in pg_stat_activity and logs automatic aggressive vacuum to prevent wraparound of table "app.public.t": index scans: 1. It does not cancel itself for conflicting locks, which is why a harmless ALTER TABLE can suddenly queue behind it.

Sizing

  • Raising it (e.g. 400M–1B) on high-XID-rate systems reduces how often big tables are rescanned, at the cost of a larger pg_xact and less safety margin.
  • Per table you can only set it lower: ALTER TABLE t SET (autovacuum_freeze_max_age = 100000000).
  • It caps others: vacuum_freeze_table_age ≤ 95%, vacuum_freeze_min_age ≤ 50%, vacuum_failsafe_age ≥ 105% of it.

Watch

SELECT datname, age(datfrozenxid) FROM pg_database ORDER BY 2 DESC;
SELECT c.oid::regclass, age(c.relfrozenxid), pg_size_pretty(pg_table_size(c.oid))
  FROM pg_class c WHERE c.relkind IN ('r','m','t')
 ORDER BY 2 DESC LIMIT 20;

If the age keeps rising past this value although vacuums run, something holds the xmin horizon back: a long transaction, an abandoned prepared transaction (pg_prepared_xacts), a stale replication slot, or a standby with hot_standby_feedback.

How to change it

Change in postgresql.conf or ALTER SYSTEM, then restart the server.

See it in context

XID wraparound and freezing Autovacuum: when tables get vacuumed VACUUM Autovacuum launcher and workers

Related parameters

vacuum_freeze_table_age vacuum_freeze_min_age vacuum_failsafe_age autovacuum_multixact_freeze_max_age

All Vacuuming parameters