SteelReed

Search

Search posts, questions…

Transactions & LockingQuestion 5 / 17

Middle

What lock types does InnoDB have — shared, exclusive, intention? Does a plain SELECT lock anything?

Short answer

A shared lock (S) lets many read but blocks writes; an exclusive lock (X) blocks everyone else. A plain SELECT takes no lock: it reads a snapshot through MVCC. An intention lock says "this table has locked rows".

sees IX, knows to waitreads MVCC snapshotTransaction wants a rowlockTake IS or IXon the tableTake S or Xon the index recordLOCK TABLES ... WRITEPlain SELECTNo lock at all

3 points to say:

  1. FOR SHARE takes S, FOR UPDATE takes X.
  2. A plain SELECT waits for nobody.
  3. Intention locks are table-level markers.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.