当前位置:网站首页>mysql意向锁
mysql意向锁
2022-07-25 15:43:00 【Leon_Jinhai_Sun】
意向锁表示某个事务正在锁定一行或者将要锁定一行,表明一个意图。它分为意向共享锁(IS)和意向排他锁(IX):
一个事务对一张表的某行添加共享锁前,必须获得对该表一个IS锁或者优先级更高的锁。
一个事务对一张表的某行添加排他锁之前,它必须对该表获取一个IX锁。
意向锁属于表锁,它不与innodb中的行锁冲突,任意两个意向锁之间也不会产生冲突,但是会与表锁(S锁和X锁)产生冲突,如下表:
兼容性 S锁 X锁
IS锁 兼容 冲突
IX锁 冲突 冲突
表锁和行锁已经保证了事务的隔离性,确保数据一致,那么为什么还要使用意向锁呢?
意向锁是在当事务加表锁时发挥作用。比如一个事务想要对表加排他锁,如果没有意向锁的话,那么该事务在加锁前需要判断当前表的每一行是否已经加了锁,如果表很大,遍历每行进行判断需要耗费大量的时间。如果使用意向锁的话,那么加表锁前,只需要判断当前表是否有意向锁即可,这样加快了对表锁的处理速度。
意向锁是有存储引擎自己维护的,是内部机制,用户无法操作意向锁。
边栏推荐
- 如何构建面向海量数据、高实时要求的企业级OLAP数据引擎?
- HDD Hangzhou station · harmonyos technical experts share the features of Huawei deveco studio
- 如何实现页面包含
- Beyond compare 4 realizes class file comparison [latest]
- LeetCode - 677 键值映射(设计)*
- Basic usage of MFC thread afxbeginthread, passing multiple parameters
- 兆骑科创海内外高层次创新创业人才服务平台,双创成果转化平台
- Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results
- Equivalent change of resistance circuit (Ⅱ)
- 推荐收藏,这或许是最全的类别型特征的编码方法总结
猜你喜欢

Wavelet transform --dwt2 and wavedec2

How matlab saves all the data after running

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

Understand "average load"

Leetcode - 359 log rate limiter (Design)

MySQL—用户和权限管控
![Beyond compare 4 realizes class file comparison [latest]](/img/ab/4babd7d4ee4ea132a6039858dd6451.png)
Beyond compare 4 realizes class file comparison [latest]

LeetCode - 303 区域和检索 - 数组不可变 (设计 前缀和数组)

Leetcode - 379 telephone directory management system (Design)
![[IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training](/img/d4/bcc577f320a893c7006177993b2e7a.png)
[IJCAI 2022] parameter efficient large model sparse training method, which greatly reduces the resources required for sparse training
随机推荐
Redis distributed lock, it's really impossible without it
Pytoch learning notes -- Summary of common functions of pytoch 1
30行自己写并发工具类(Semaphore, CyclicBarrier, CountDownLatch)
Matlab randInt, matlab randInt function usage "recommended collection"
产品动态丨Android 13 高效适配全新升级
基于Caffe ResNet-50网络实现图片分类(仅推理)的实验复现
Gary marcus: learning a language is more difficult than you think
Pytoch learning notes - Teacher Liu Er RNN advanced chapter - code comments and results
The difference between mouseover and mouseenter
Cf888g clever dictionary tree + violent divide and conquer (XOR minimum spanning tree)
Hdu3873 shortest path with dependency (topological sorting)
如何解决跨域问题
Gary Marcus: 学习语言比你想象的更难
ServletConfig 类和ServletContext 类
[Shakespeare: keep the fun of being a man]
Redis分布式锁,没它真不行
JVM - classloader and parental delegation model
Zhaoqi Kechuang high-quality overseas returnee talent entrepreneurship and innovation service platform, online live broadcast Roadshow
物理防火墙是什么?有什么作用?
Leetcode - 362 knock counter (Design)