How does MVCC allow a database to handle concurrent reads and writes without locking the entire table? What are the storage implications of keeping multiple versions of a row?
Last updated
MVCC (Multi-Version Concurrency Control) writes a new row version on update instead of overwriting. Each transaction reads the version visible in its snapshot, so readers and writers don't block each other. Writers still lock rows against other writers.
Storage cost: old versions pile up (dead tuples or undo segments) and must be cleaned up, e.g. by
VACUUMin Postgres.Long-running transactions block cleanup and cause bloat. Indexes pointing at multiple versions add further overhead.
- https://vipulvyas.medium.com/a-comprehensive-guide-to-postgresql-mvcc-transactions-isolation-physical-storage-and-vacuum-7e31d028d488
- https://planetscale.com/blog/postgresql-mvcc
- https://goldlapel.com/glossary/postgres/mvcc
- https://medium.com/@kp481216/deep-dive-into-multi-version-concurrency-control-mvcc-and-isolation-levels-0ff39afde0f1
- https://www.phoenixdata.ai/glossary/multiversion-concurrency-control
- https://medium.com/@DevTarangini/locks-mvcc-and-isolation-levels-95c2b32cfd9b
- https://www.postgresql.org/docs/current/mvcc-intro.html
- https://blog.lokesh1729.com/system-design-interview-multi-version-concurrency-control-in-databases-the-icebreaker-for-deciding-which-relational-database-to-choose