MVCC
InnoDB uses MVCC to allow consistent reads without blocking. Each transaction sees a snapshot of the data from when it started.
InnoDB uses MVCC to allow consistent reads without blocking. Each transaction sees a snapshot of the data from when it started.
-- Session 1 -- Session 2
START TRANSACTION; START TRANSACTION;
-- Sees snapshot from T1 start SELECT balance FROM accounts WHERE id=1;
-- Returns 1000 (snapshot)
UPDATE accounts SET balance=500 -- Session 2 still sees 1000
WHERE id=1;
COMMIT; SELECT balance FROM accounts WHERE id=1;
-- Still sees 1000 (REPEATABLE READ)
COMMIT; -- Now next read sees 500
MVCC means readers never block writers and writers never block readers — high concurrency.