Home  >  Article  >  Database  >  What granular locks are there in mysql?

What granular locks are there in mysql?

WBOY
WBOYforward
2023-05-26 13:49:061285browse

1. Table lock

Table lock refers to locking the entire table when locking. When the next transaction accesses the table, it must wait until the previous transaction unlocks the lock before accessing the table

Features include large granularity, simple locking, and easy conflict.

2. Row lock

means that when locking, one or more rows of records in the table are locked. When other transactions access the same table, only the locked records cannot Access, other records can be accessed normally

The characteristics are small granularity, locking is more troublesome than table locks, less prone to collisions, and supports higher concurrency than table locks

3. Record lock

Record lock is also a type of lock, but the scope of record lock is only a certain record of the table. Record lock is a transaction lock and only locks a certain record of the table.

4. Gap lock

Gap lock is a kind of lock. After the transaction is locked, the gap lock locks a certain interval of the table record. A gap is formed when a gap occurs between adjacent IDs, and the principle of left and right closure is followed.

5. Key lock

Lock key is also a type of row lock. It is the default row lock algorithm of INNODB. In short, it is a combination of record key and gap key. , the temporary key locks the queried record, locks all gap spaces within the query range, and locks the next adjacent interval.

The above is the detailed content of What granular locks are there in mysql?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete