MVCC (Multi-Version Concurrency Control)
MVCC (Multi-Version Concurrency Control) is a SQL statement in the Transactions category. MVCC is the mechanism behind snapshot isolation. Readers see a consistent snapshot, writers create new versions. The syntax is -- MVCC allows concurrent read/write by keeping multiple versions of data rows.. It returns concurrency mechanism. A typical example: -- How MVCC works: -- 1. Transaction A starts and reads row id=1 (version 1) -- 2. Transaction B updates row id=1 (creates version 2) -- 3. Transaction A reads row id=1 again -- 4. Due to MVCC, A still sees version 1 (consistent snapshot) -- 5. A commits, then reads again: now sees version 2 -- Database implementations: -- PostgreSQL: stores old row versions in table (no undo log)… A close relative is BEGIN / START TRANSACTION, which begins a new transaction. Changes made within are invisible to others until COMMIT. A close relative is COMMIT, which saves all changes made in the current transaction permanently.