Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Can MYSQL GAP locks be compatible in the same query segment?

Shulou Source: shulou.com Published: 2022-06-02 04:08:35 09月20日 Update

This article mainly introduces "MYSQL GAP lock in the same query segment can not be compatible", in daily operation, I believe many people in MYSQL GAP lock in the same query segment can not be compatible with the problem there are doubts, Xiaobian consulted all kinds of information, sorted out simple and easy to use operation methods, I hope to answer everyone "MYSQL GAP lock in the same query segment can not be compatible" doubts helpful! Next, please follow the small series to learn together!

MYSQL lock, has always been a hot spot of research, which GAP lock research has been very HOT, if someone asks, in the same query segment, whether GAP lock can be "compatible." How do you answer? We don't answer directly here. Let's do an experiment.

Let's be clear about how this experiment was done.

use test;

CREATE TABLE IF NOT EXISTS `gap_test`(

`id` INT UNSIGNED AUTO_INCREMENT,

`name` VARCHAR(20) ,

`age` tinyint ,

`date` DATETIME,

PRIMARY KEY ( `id` )

)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 row_format = DYNAMIC;

insert into `gap_test` (name,age,date) values ('austin',18,now());

insert into `gap_test` (name,age,date) values ('tim',28,now());

insert into `gap_test` (name,age,date) values ('johnny',16,now());

insert into `gap_test` (name,age,date) values ('jason',17,now());

insert into `gap_test` (name,age,date) values ('winnset',38,now());

create index ix_gap_test_age on gap_test(age);

Here's the initial data.

Scenario 1,

Session 1

Session 2

Below we look at the lock information

lock generated, but no gap lock

2 Case 2

session 1

session 2

information

case 3

session 1

Session 2

results

case 4

session 1

session 2

The result is unlocked.

case 5

session 1

session 2

results

case 6

session 1

session 2

results

case 7

session 1

session 2

results

case 8

session 1

session 2

results

At this point, the study of "MYSQL GAP lock can be compatible in the same query segment" is over, hoping to solve everyone's doubts. Theory and practice can better match to help everyone learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!

Tags: Situation result query learning information more experiment help research practical clear next situation data article method hot spot theory knowledge article Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Shulou Information Apple MySQL Docker