When a row in MySQL/InnoDB is locked (whether implicitly due to the isolation level of a transaction, or explicitly using SELECT * ... FOR UPDATE
or ``... LOCK IN SHARE MODE`):
Does this lock also apply to all index records associated with the row, or will only the index record used to access the lock by the locking statement itself be locked?
As an example, assume that there exists a table with columns x
, y
, and z
, where x
and y
are indexed.
Will the statement SELECT * FROM Table WHERE x = foo
, which returns one record with (x = foo, y = bar, z = c)
also make all statements like SELECT * FROM Table WHERE y = bar
wait on the lock, or can these still be executed concurrently (assuming that they will not attempt to modify the locked row itself, of course)?
Update: Please note that the question is not about index record or gap locks in general. It is about the specific case of a locking read via scanning index x
, and whether or not that will make queries scanning over y
wait.