Interview › Databases & Caching
What is VACUUM in PostgreSQL, and why is autovacuum important?
Databases & Caching · Basic level
Answer
PostgreSQL and MySQL differ operationally in storage behavior, MVCC implementation, replication, indexing, planner behavior, extensions, and maintenance. PostgreSQL MVCC keeps row versions for concurrent snapshots, and VACUUM/autovacuum is essential to clean dead tuples and prevent wraparound.
Technical explanation
PostgreSQL readers do not usually block writers, but old row versions create dead tuples and bloat if vacuum falls behind.
Long-running transactions can prevent cleanup and increase wraparound risk.
Operational checks should include dead tuples, transaction age, autovacuum timing, slow queries, and extension compatibility.
Hands-on example
PostgreSQL health checks:
SELECT relname, n_live_tup, n_dead_tup, last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC LIMIT 20;
SELECT datname, age(datfrozenxid) AS xid_age FROM pg_database ORDER BY xid_age DESC;If values are high, investigate long transactions, tune autovacuum per hot table, and schedule safe VACUUM work.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Databases & Caching interview questions
- What is MVCC, and how does PostgreSQL implement it?
- What is RDS Proxy, and what problem does it solve?
- What is connection pooling, and why does it matter for RDS (e.g., RDS Proxy)?
- How do you scale an RDS database vertically and what is the downtime impact?
- What are common causes of high RDS CPU, and how do you investigate?
- What is Performance Insights, and what does it help you find?
- How do you monitor RDS performance (CloudWatch, Performance Insights, Enhanced Monitoring)?
- What is a blue-green deployment for RDS, and how does it reduce upgrade risk?