Vacuum performs key maintenance on PostgreSQL data files:
- Recovers free space consumed by older versions of records under MVCC.
- Updates statistics used by the query planner.
- Updates the visibility map, speeding up index-only scans.
- Prevents loss of very old data caused by transaction ID (
vacuumcan run in parallel with other clients/operations.
vacuum fullrequires an
access exclusivelock. This should be avoidable if
vacuumis performed routinely.
select relname as tablename , n_live_tup as livetuples , n_dead_tup as deadtuples , last_autovacuum as autovacuum , last_autoanalyze as autoanalyze from pg_stat_user_tables;
select category , name , setting , unit , source , min_val , max_val from pg_settings where category = 'Autovacuum';