Home > Database > Mysql Tutorial > How to use mysql gap lock

How to use mysql gap lock

王林
Release: 2023-06-02 21:56:28
forward
1206 people have browsed it

Explanation

1. When we use range conditions to retrieve data and request shared or exclusive locks, InnoDB will lock the index items of existing data records that meet the conditions; Records whose key values ​​are within the condition range but do not exist are called gaps.

2. InnoDB will also lock this gap. This lock mechanism is the so-called gap lock.

Note

If the execution condition is that the range is too large, InnoDB will lock all index key values ​​in the entire range, which can easily affect performance.

Example

Transaction-A
mysql> update innodb_lock set k=66 where id >=6;
Query OK, 1 row affected (0.63 sec)
mysql> commit;
 
Transaction-B
mysql> insert into innodb_lock (id,k,v) values(7,'7','7000');
Query OK, 1 row affected (18.99 sec)
Copy after login

The above is the detailed content of How to use mysql gap 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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template