Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report