IT lexicon › Database › VACUUM (Postgres)

VACUUM (Postgres)

Database På svenska → Updated: 2026-07-30

PostgreSQL maintenance that cleans up "dead rows" (dead tuples) left behind by MVCC after UPDATE/DELETE. Without VACUUM, tables bloat and transaction IDs can run out. Usually handled automatically by autovacuum.

Why it's needed: PostgreSQL never overwrites a row — an UPDATE creates a new version and marks the old one dead. VACUUM frees the space for reuse (but doesn't shrink the file — that's VACUUM FULL with an exclusive lock). The other critical task: "freezing" old rows to prevent transaction ID wraparound (a catastrophe that can halt the database). VACUUM ANALYZE also updates the planner's statistics. Bloat = a common cause of mysterious performance degradation. Monitor via pg_stat_user_tables. PostgreSQL 17+ greatly improved VACUUM's memory usage.

← Back to the lexicon