mysql fragmentary knowledge summary

  1. sql operation of the lock occupied within the same transaction locks are released when the transaction is committed, so far as possible exclusive lock on the back

2.not in, like before the match, or does not support indexing

3. affairs can set return point, the question arises, can jump back to the return point

4. Try not to call the service layer service layer, because the timing of the release of the lock is the time of the transaction commits, so to avoid long transaction, try to ensure short transactions, reduce lock takes time.

5.myisam Although the table-level locking, but supports concurrent inserts, a process that is in the process of reading table, insert the end of the table, concurrent_insert default is 1, 2 is set to the middle of the table even if the reading has been deleted in the industry can be complicated by the insertion

The biggest difference 6.InnoDB and MyISAM are two points: First, to support the transaction, the second is using row-level locking

7.MyISAM using table level lock, a deadlock situation does not occur, and the lock is separate for read and write locks, read locks reentrant, between the read-write lock are mutually exclusive. And while waiting for the lock, while waiting write lock and read lock, write lock will give priority allocation lock (by default, it can be configured to modify)

8.InnoDB occurred Solution deadlock is to lead to a deadlock and hold less transaction rollback row lock it.

9. a transaction if there is an update operation, should apply directly for an exclusive lock, rather than to apply for shared lock, behind the update and apply for exclusive lock, if both sides of the transaction have both shared locks, but all went to the same bank for exclusive lock, all in the case of waiting for the other to release the shared lock, the deadlock occurs.

10. A shared lock, exclusive lock is a lock innodb read and write data to apply only isolation level is more repeatable read will apply for a shared lock, intent shared locks, intent exclusive lock is applying shared locks and exclusive locks lock (innodb automatic plus lock)

  1. InnoDB row lock is achieved through the implementation locked to the index, if the index sql statement does not hit, then use table locks.

  2. Gap locks, mysql to solve the lock phantom read occurs, repeatable read level and above will apply for the lock, mysql will meet the requirements of data plus locks when the transaction through a hoe to a number of conditions to query the data when will plus a gap lock, then b transaction data to meet the requirements of these pruning or add data to meet this condition will be blocked to wait for a lock, according to the index depends on the specific hit condition which of a plurality of conditions , lock the index hit.

13.MVCC need to control the data returned by the version number and improve concurrency.

Guess you like

Origin blog.51cto.com/14471175/2433692