MVCC and Vacuum
Cheat sheet · https://pcornel.dk/topic.php?topic=6174
Answer
MVCC keeps old row versions for concurrent readers. In PostgreSQL, VACUUM removes dead versions and prevents transaction ID wraparound; autovacuum does this automatically.
Remember
Long-running or idle-in-transaction sessions stop vacuum from cleaning. Tune autovacuum per table for busy tables. Wraparound warnings are urgent.
First checks
SELECT relname,n_dead_tup,last_autovacuum FROM pg_stat_user_tables ORDER BY n_dead_tup DESC;— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Verify in this order
updates/deletes create dead tuples → vacuum reclaims → visibility map → freeze
Where it usually breaks
An open transaction for hours causes bloat across the database.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6174