Identify and resolve aggressive vacuum blockers in RDS for PostgreSQL
In PostgreSQL, vacuuming is vital for ensuring database health as it reclaims storage and
prevents transaction ID wraparound
The postgres_get_av_diag()
function helps identify issues that either prevent
or delay the aggressive vacuum progress. Suggestions are provided, which may include commands to
resolve the issue where it is identifiable or guidance for further diagnostics where the issue
is not identifiable. Aggressive vacuum blockers are reported when the age exceeds RDS' adaptive
autovacuum threshold of 500 million transaction IDs.
What is the age of the transaction ID?
The age()
function for transaction IDs calculates the number of transactions
that have occurred since the oldest unfrozen transaction ID for a database
(pg_database.datfrozenxid
) or table (pg_class.relfrozenxid
). This
value indicates database activity since the last aggressive vacuum operation and highlights the
likely workload for upcoming VACUUM processes.
What is an aggressive vacuum?
An aggressive VACUUM operation conducts a comprehensive scan of all pages within a table,
including those typically skipped during regular VACUUMs. This thorough scan aims to "freeze"
transaction IDs approaching their maximum age, effectively preventing a situation known as
transaction ID wraparound
For postgres_get_av_diag()
to report blockers, the blocker must be at least 500
million transactions old.