Home > Database > Mysql Tutorial > How to use mysql insert intention lock

How to use mysql insert intention lock

PHPz
Release: 2023-05-30 09:23:27
forward
1439 people have browsed it

1. The insertion intention lock is a gap lock, not an intention lock. It is generated by the insert operation. When multiple transactions write different data to the same index gap at the same time, there is no need to wait for other transactions to complete, and no lock wait will occur.

Assume that there is a record index containing key values ​​4 and 7, and different transactions insert 5 and 6 respectively. Each transaction will generate an insertion intention lock, and add it to between 4-7 to get the inserted row. Exclusive locks, but not mutual locks, because the data rows do not conflict.

2. Inserting intention locks will not prevent any locks, and inserting records will hold record locks.

Example

insert into test_user(user_id,name,age) values(2,'b',10)
------- TRX HAS BEEN WAITING 18 SEC FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 6628 page no 4 n bits 72 index `index_user` of table `test`.`test_user` trx id 117851203
插入意向锁
lock_mode X insert intention waiting
Record lock, heap no 1 PHYSICAL RECORD: n_fields 1; compact format; info bits 0
 0: len 8; hex 73757072656d756d; asc supremum;;
Copy after login

The above is the detailed content of How to use mysql insert intention lock. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template