SimuVedaSystem Design Lab Open in the lab

Database internals / Advanced / 5 min / Updated

MVCC: snapshots, locks and table bloat

Run a long report while orders arrive. Read locks make writers wait; MVCC snapshots let both run but keep old row versions until vacuum.

Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.

In short

What is MVCC?

MVCC keeps several versions of a row so each transaction reads a consistent snapshot without locking writers.

Why does it matter?

Long reads and constant writes must run together on the same tables.

What is the trade-off?

No reader-writer blocking, but old versions need vacuum and long transactions cause bloat.

How do you explain it in an interview?

"Postgres MVCC with snapshot isolation, autovacuum tuned, alerts on long-running transactions and table bloat."

Check yourself

How does MVCC let a long report run while orders are written?

Answer: Writers create new row versions; the report keeps reading its snapshot of old versions. Readers never block writers and writers never block readers; each sees a consistent snapshot.

What is table bloat in Postgres?

Answer: Old row versions nobody needs any more, still taking space until vacuum removes them. Vacuum reclaims dead versions; long open transactions stop it from cleaning.

Why is a forgotten open transaction dangerous with MVCC?

Answer: Vacuum must keep every version it might still read, so bloat grows. The oldest open snapshot sets how far cleanup can go.

See it happen in the simulation →

mvccmulti-version concurrency controlsnapshot isolationvacuumtable bloatpostgreslocksdatabase internals

More in database internals