当前位置:网站首页>mysql意向锁
mysql意向锁
2022-07-25 15:43:00 【Leon_Jinhai_Sun】
意向锁表示某个事务正在锁定一行或者将要锁定一行,表明一个意图。它分为意向共享锁(IS)和意向排他锁(IX):
一个事务对一张表的某行添加共享锁前,必须获得对该表一个IS锁或者优先级更高的锁。
一个事务对一张表的某行添加排他锁之前,它必须对该表获取一个IX锁。
意向锁属于表锁,它不与innodb中的行锁冲突,任意两个意向锁之间也不会产生冲突,但是会与表锁(S锁和X锁)产生冲突,如下表:
兼容性 S锁 X锁
IS锁 兼容 冲突
IX锁 冲突 冲突
表锁和行锁已经保证了事务的隔离性,确保数据一致,那么为什么还要使用意向锁呢?
意向锁是在当事务加表锁时发挥作用。比如一个事务想要对表加排他锁,如果没有意向锁的话,那么该事务在加锁前需要判断当前表的每一行是否已经加了锁,如果表很大,遍历每行进行判断需要耗费大量的时间。如果使用意向锁的话,那么加表锁前,只需要判断当前表是否有意向锁即可,这样加快了对表锁的处理速度。
意向锁是有存储引擎自己维护的,是内部机制,用户无法操作意向锁。
边栏推荐
- Okaleido launched the fusion mining mode, which is the only way for Oka to verify the current output
- 2019 Zhejiang race c-wrong arrangement, greedy
- 兆骑科创高质量海归人才双创服务平台,线上直播路演
- 【服务器数据恢复】HP EVA服务器存储意外断电导致RAID信息丢失的数据恢复案例
- MySQL教程67-使用DISTINCT过滤重复数据
- Activity review | July 6 Anyuan AI X machine heart series lecture No. 2 | MIT professor Max tegmark shares "symbiotic evolution of human and AI"
- Leetcode - 380 o (1) time to insert, delete and get random elements (design hash table + array)
- IDEA—点击文件代码与目录自动同步对应
- MySQL tutorial 66 data table query statement
- Pytoch learning notes -- Summary of common functions 2
猜你喜欢

Window system black window redis error 20creating server TCP listening socket *: 6379: listen: unknown error19-07-28

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

Huawei 2023 starts to warm up in advance! Zuo Shen's program code interview guide comes in handy

如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?

开发者如何为React Native选择合适的数据库

Redis distributed lock, it's really impossible without it

JVM—类加载器和双亲委派模型

Geogle colab notes 1-- run the.Py file on the cloud hard disk of Geogle

CVPR 2022 | in depth study of batch normalized estimation offset in network

Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results
随机推荐
LeetCode - 362 敲击计数器(设计)
Sword finger offer | number of 1 in binary
How matlab produces random complex sequences
如何解决跨域问题
MySQL教程66-数据表查询语句
ML - Speech - traditional speech model
LeetCode - 379 电话目录管理系统(设计)
LeetCode - 677 键值映射(设计)*
Redis distributed lock, it's really impossible without it
Zhaoqi Kechuang high-level innovation and Entrepreneurship Talent Service Platform at home and abroad, mass entrepreneurship and innovation achievement transformation platform
十字链表的存储结构
Dpdk packet receiving and sending problem case: non packet receiving problem location triggered by mismatched packet sending and receiving function
R语言偏相关性计算(Partial Correlation)、使用ggm包的pcor函数计算偏相关性(Partial Correlations)
谷歌博客:采用多重游戏决策Transformer训练通用智能体
华为2023届提前批预热开始!左 神的程序代码面试指南终派上用场
[Shakespeare: keep the fun of being a man]
Why is preparestatement better and safer?
Baseband simulation system experiment of 4pam in Gaussian channel and Rayleigh channel
Leetcode - 707 design linked list (Design)
Beyond Compare 4 实现class文件对比【最新】