Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk5 min

MySQL MVCC Explained: Snapshots, Isolation Levels, and Undo History

InnoDB MVCC lets consistent reads use snapshots while concurrent transactions modify rows. Learn how isolation levels, undo versions, locking reads, and open transactions affect what you see.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In MySQL’s InnoDB engine, multi-version concurrency control (MVCC) lets ordinary reads see a consistent snapshot while other transactions change rows. InnoDB uses undo information to reconstruct older row versions when needed. The snapshot’s timing depends on the transaction’s isolation level; MVCC does not make every query lock-free.

This guide describes behavior documented in the MySQL 8.4 Reference Manual. Check the manual for your deployed version before relying on version-specific details.

As an Amazon Associate I earn from qualifying purchases.

How does MVCC work in MySQL?

The MySQL 8.4 Reference Manual describes InnoDB as “a multi-version storage engine.” Rather than keeping a complete extra copy of every table, InnoDB tracks changes so it can present the appropriate version of a changed row to a consistent read.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

InnoDB row metadata includes a transaction identifier and a pointer to undo information. When a query needs an earlier version, InnoDB can follow that undo history to reconstruct the row as it appeared at the query’s snapshot point. Undo information also enables rollback: changes made by a transaction can be undone if it does not commit.

Insert undo is needed to roll back an inserted row and can be discarded after commit. Update undo can also be needed to reconstruct prior values for consistent reads, so it must remain available while an active snapshot might still need it. See InnoDB Multi-Versioning.

What is a consistent read in InnoDB?

The manual defines it this way: “A consistent read means that InnoDB uses multi-versioning to present to a query a snapshot of the database at a point in time.” Ordinary SELECT statements are consistent, nonlocking reads by default under InnoDB’s REPEATABLE READ and READ COMMITTED isolation levels.

A consistent read sees changes committed before its snapshot was established. It does not see changes committed afterward or uncommitted changes from other transactions. It does see the current transaction’s own earlier writes. That exception can produce a view that never existed as a complete database state: a transaction might see its own newly updated row alongside older snapshot versions of other rows. Details are in Consistent Nonlocking Reads.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When is the snapshot established?

For InnoDB’s default REPEATABLE READ level, the first consistent read in a transaction establishes the snapshot used by subsequent consistent reads in that transaction. The snapshot is not necessarily taken when the transaction starts. A commit ends the transaction; a later transaction’s first consistent read establishes a new snapshot.

READ COMMITTED instead gives each consistent read a fresh snapshot. A later plain SELECT can therefore see commits that an earlier SELECT in the same transaction could not see. The manual documents these behaviors in Transaction Isolation Levels.

A two-session timeline

  1. Session A begins a transaction and runs a plain SELECT. This establishes its snapshot under REPEATABLE READ.
  2. Session B updates a row and commits.
  3. Session A runs the same plain SELECT again. Under REPEATABLE READ, it continues to see the earlier snapshot; under READ COMMITTED, this read can see Session B’s committed change.

This timeline concerns ordinary consistent reads. Writes and locking reads have distinct behavior; do not assume every statement in a transaction uses the same historical view.

REPEATABLE READ vs. READ COMMITTED

Behavior REPEATABLE READ READ COMMITTED
InnoDB default Yes No
Snapshot timing for ordinary consistent reads The first consistent read establishes the snapshot reused by later consistent reads in the transaction. Each consistent read obtains a fresh snapshot.
Effect on repeated plain SELECTs They remain consistent with one another, subject to the transaction seeing its own writes. A later read can see commits that an earlier read could not.
Locking behavior relevant to searches Depending on the statement and index search, locking operations can use gap or next-key locks. Gap locking for searches and index scans is disabled, except for foreign-key and duplicate-key checks. An UPDATE may use a semi-consistent read in the documented case.

These are isolation-level rules, not a guarantee that every query plan or locking operation behaves identically. Lock scope depends on the statement and indexes involved. InnoDB also supports READ UNCOMMITTED, which can expose uncommitted changes (dirty reads), and SERIALIZABLE, which is stricter and changes plain SELECT behavior when autocommit is disabled. See the MySQL 8.4 isolation-level documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why can a query show an older value?

If a transaction is using REPEATABLE READ, a plain consistent read after another transaction commits may still use the snapshot established by the transaction’s first consistent read. The older value is intentional: it keeps ordinary reads in that transaction consistent with one another.

Check whether the session is inside a transaction, which isolation level it uses, and whether an earlier consistent read established the snapshot. A commit or rollback ends that transaction’s snapshot; a subsequent transaction can see newer committed data. Also distinguish plain reads from locking reads and data-changing statements, which do not simply behave like ordinary snapshot reads.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Does MVCC mean queries never lock?

No. Ordinary consistent reads under REPEATABLE READ and READ COMMITTED do not set locks on the tables they access, allowing concurrent sessions to modify rows while those reads run. InnoDB also uses row-level locking, and write statements and explicit locking reads have locking behavior.

Use a locking read for read-then-change decisions

Suppose an application checks that a parent row exists before inserting a related child row. A plain snapshot read does not protect the parent from being deleted by another transaction before the insert. A locking read can protect the row until the transaction completes:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
START TRANSACTION;
SELECT id FROM parent WHERE id = 42 FOR SHARE;
-- Insert the related child row here.
COMMIT;

FOR SHARE takes shared locks on rows read. FOR UPDATE locks encountered index records and associated entries in a manner similar to an UPDATE. These locks are released at commit or rollback. The exact scope depends on the search and indexes; see InnoDB Locking Reads.

Do not treat a data-changing statement as if it necessarily reads only the same historical snapshot as a plain SELECT. MySQL documents differences between consistent nonlocking reads and locking statements, so mixing them in a REPEATABLE READ transaction can expose different views of data.

Can a long-running transaction make undo history grow?

Yes. If an active snapshot could still need an older row version, InnoDB cannot discard the corresponding update undo records. A long-running transaction—including a read-only transaction that performs consistent reads—can delay purge and contribute to a growing History list length. MySQL recommends committing or rolling back transactions regularly, including read-only transactions that issue consistent reads. See InnoDB Purge Configuration.

What to check

  • Inspect the TRANSACTIONS section of SHOW ENGINE INNODB STATUS for the History list length.
  • Look for old or open transactions that may still require earlier row versions.
  • Treat the history-list value as a clue to purge lag and transaction age, not as a diagnosis by itself.

The MySQL 8.4 manual says History list length is “usually less than a few thousand.” This is a general observation, not a target, threshold, or guarantee.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.