mysql optimization - mysql innodb table lock problem
淡淡烟草味
淡淡烟草味 2017-05-24 11:32:59
0
2
627

After testing, I found that the following situations will cause table locks
1.like
2.update, delete unconditional operations
3.update,delete are conditional operations but not primary key operations
Select will not lock the table whether it is conditional or unconditional, whether the condition is primary key or index, Is this correct? Is there something wrong with my test?

淡淡烟草味
淡淡烟草味

reply all(2)
曾经蜡笔没有小新

select can specify various levels of locks such as shared locks, exclusive locks, etc., such as select ... FOR UPDATE.
As for why locks are needed, here is a simple example. For example, if you have a document that inherits from the previous document, you can choose to add a read lock and lock the previous document to prevent others from modifying the previous document before you submit it. , causing data inconsistency.

習慣沉默

As long as the condition does not contain the primary key, or contains the primary key but is not an equal sign or IN, the entire table will be locked, which includes all three situations in the question.

Whether it is locking the entire table or locking a few rows, select adds read locks, and update and delete add write locks. As for what read locks and write locks are, you can Google them. As for the details, you can also look at the Transaction Isolation Level, which I won’t go into here.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!