Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the granularity locks in mysql

Shulou Source: shulou.com Published: 2022-05-31 17:45:51 10月26日 Update

This article mainly introduces the relevant knowledge of what granularity locks are in mysql, the content is detailed and easy to understand, the operation is simple and fast, and has a certain reference value. I believe you will gain something after reading this mysql article about granularity locks. Let's take a look at it.

1. Table lock

A table lock means that the entire table is locked when locked. When the next transaction accesses the table, it must wait until the previous transaction is unlocked before accessing the table.

It is characterized by large granularity, simple locking and easy conflict.

2. Row lock

It means that when a table is locked, one or more rows of records are locked. When other transactions access the same table, only locked records cannot be accessed, and other records can be accessed normally.

It is characterized by small granularity, more troublesome lock than table lock, not easy to collision, and higher concurrency than table lock.

3. Record lock

Record lock is also a kind of lock, but the scope of record lock is only a record of a table, and a record lock is only a record of a table locked after a transaction lock.

4. Clearance lock

Gap lock is a kind of lock, which locks a certain interval of the table record after the transaction is locked. When there is a gap between the adjacent ID of the table, it forms a gap, which follows the principle of closing left and right.

5. Key lock

Key lock is also a kind of row lock, which is the default algorithm of INNODB row lock. In short, it records the combination of key and gap key, locks the record of query by temporary key, locks all gap spaces in the range query, and locks the next adjacent interval.

This is the end of the article on "what granularity locks are there in mysql". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what granularity locks are in mysql". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Gap granularity transaction knowledge key content interval only characteristics article scope query not easy between value principle but at the same time simple operation article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Shulou Tech Info Docker Linux