当前位置:网站首页>MySQL four locks
MySQL four locks
2022-07-27 18:23:00 【zh_ Tnis】
Row-level locks :
- stay mysql in , Row level lock is not a direct lock record , It's the lock index , Index is divided into primary key index and non primary key index .
- One SQL Statement operates the primary key index , that MySQL Lock the primary key index .
- One SQL Statement operates on a non primary key index , that MySQL Lock the non primary key index first , Then lock the relevant non primary key index .
- stay InnoDB in , If SQL The statement does not involve an index , Then the records will be locked through the hidden cluster index . That is, the data is not searched through the index , that InnDB All the data in the table will be locked . No index , When searching records, you need to scan the whole table , Scan the whole table , Then lock the table .
- row-level loking , Lock a row of records
- Spending big , Full lock , There will be a deadlock .
- Small particle size of cable , The probability of lock conflict is small , High concurrency efficiency .
- Suitable for concurrent writing .
Table lock :
- Table lock , Generally, it refers to table structure shared lock , Yes, this table cannot be executed DDL operation , But yes DML Operation is not limited . Before row level locks, you need to add table structure shared locks . If you use a table lock , Other customers will not be able to query , Therefore, row level locks are generally used in development .
- table-level locking, Lock the whole table .
- Low overhead , Locked fast , No deadlock .
- Big lock size , The probability of lock conflict is high , Concurrency is inefficient .
- Suitable for inquiry .
Optimism lock :
- Optimistic locking believes that concurrent operations are difficult to occur , But it doesn't necessarily happen , All measures exist to deal with this situation , That's version number version, Every time you modify the data ,version Change once .
- for example ,A The window is set on the day of 12:00 The stage operation updates the data in the table ,12:02 Press the OK key . But on the same day 12:01 Stage B The window updates and determines the data in the table , Then the version number of the table version It has changed , At the same time A Data update of window operation failed . This also indicates that concurrency problems have occurred , This operation needs to be rolled back .
- When reading data , No locks .
Pessimistic locking :
- And optimism , Pessimistic locks believe that concurrency problems are very easy to occur .
- A When the window is updating data ,B The window cannot manipulate this data ,B The window wants to update data , Must wait A Only after the window operation is completed .
- During data operation , Whether reading or writing , Will lock the records , To prevent other threads from changing data .
边栏推荐
- Deep learning: Gan optimization method dcgan case
- 动态链表3队列的链式存储结构(LinkedQueue实现)
- 又一个时代的终结!
- 记一次 .NET 某智慧物流 WCS系统 CPU 爆高分析
- 动态链表4单向循环链表(LoopSingle实现)
- NowCoder(5选)
- 施耐德电气、欧莱雅等企业巨头如何开放式创新?DEMO WORLD世界创新峰会揭秘
- 展锐鲜苗:赋能全场景应用,海量数据需要AI与IoT融合
- Salesforce Dynamic Forms
- Here comes the first 5g SOC of MediaTek! A77+g77+apu3.0, officially released on November 26!
猜你喜欢
![[MIT 6.S081] Lab8: locks](/img/9f/0ff7a0226837a3c420f49e6da8209f.png)
[MIT 6.S081] Lab8: locks

深度识别:论文阅读_2S-AGCN CVPR2019(基于骨架的动作识别的两流自适应图卷积网络)
![[learning notes] advanced version of MySQL database - index optimization, slow query, locking mechanism, etc](/img/7a/7497a73b435c3ed4fa0f3a3e908298.jpg)
[learning notes] advanced version of MySQL database - index optimization, slow query, locking mechanism, etc

深度学习-论文阅读:动作结构性图卷积网络AS-GCN

Set up SSO based on SAML 2.0 in salesforce and enable JIT user provisioning (between SF orgs / between SF org and experience cloud / other IDPs)

解决Reids不能被其他IP访问

深度学习:GCN图分类案例

View port PID and end process

How do corporate giants such as Schneider Electric and L'Oreal make open innovation? Uncover secrets of demo World Innovation Summit
![[MIT 6.S081] Lec 8: Page faults 笔记](/img/e2/0f5332dd9d2b439bcf29e87a9fa27f.png)
[MIT 6.S081] Lec 8: Page faults 笔记
随机推荐
After being "expelled" from bitland, the Jank group said for the first time: it will return as soon as possible through legal channels!
【学习笔记】MySQL数据库高级版 - 索引优化、慢查询、锁机制等
【学习笔记】热点账户问题的解决方案
Hutool digital computing
记一次 .NET 某智慧物流 WCS系统 CPU 爆高分析
[MIT 6.S081] Lec 9: Interrupts 笔记
MySQL solves the problem of insert failure caused by duplicate unique indexes
[MIT 6.S081] Lab 9: file system
Deep learning: stgcn learning notes
Six relationships of classes -- the difference between dependency and Association
Interview FAQs 12
数据库的常用命令1
3. Opencv geometric transformation
Marvell公布旗下Arm服务器芯片路线图,下一代性能将比ThunderX2高两倍
The end of another era!
Golang concurrent cache breakdown or merge request
GIS数据漫谈(五)— 地理坐标系统
深度学习:GAN优化方法-DCGAN案例
[learning notes] classification of locks in the database
宣布收购文晔30%股份,大联大意欲何为?