当前位置:网站首页>MySql实战45讲【行锁】
MySql实战45讲【行锁】
2022-07-03 02:59:00 【小鱼儿2020】
07 | 行锁功过:怎么减少行锁对性能的影响?
InnoDB是支持行锁的.
行锁就是针对数据表中行记录的锁。这很好理解,比如事务 A 更新了一行,而这时候事务 B 也要更新同一行,则必须等事务 A 的操作完成后才能进行更新.
从两阶段锁说起
如果你的事务中需要锁多个行,要把最可能造成锁冲突、最可能影响并发度的锁尽量往后放
死锁和死锁检测
当并发系统中不同线程出现循环资源依赖,涉及的线程都在等待别的线程释放资源时,就会导致这几个线程都进入无限等待的状态,称为死锁。这里我用数据库中的行锁举个例子。
-- 查询事务锁等待时间,单位秒,非交互式
show variables like "innodb_lock_wait_timeout%"
set innodb_lock_wait_timeout=100;
innodb_lock_wait_timeout指的是事务等待获取资源等待的最长时间,
超过这个时间还未分配到资源则会返回应用失败
-- 死锁检查是否启用
show variables like "innodb_deadlock_detect%"

小结
innodb行级锁是通过锁索引记录实现的。
如果update 没有走索引,innodb内部是全表根据主键索引逐行扫描 逐行加锁,事务提交的时候统一释放锁。
边栏推荐
- xiaodi-笔记
- SQL Server Query spécifie la structure de la table
- Check log4j problems using stain analysis
- leetcode540
- open file in 'w' mode: IOError: [Errno 2] No such file or directory
- Joking about Domain Driven Design (III) -- Dilemma
- Add automatic model generation function to hade
- C language beginner level - pointer explanation - paoding jieniu chapter
- L'index des paramètres d'erreur est sorti de la plage pour les requêtes floues (1 > Nombre de paramètres, qui est 0)
- 左值右指解释的比较好的
猜你喜欢
![[shutter] banner carousel component (shutter_wiper plug-in | swiper component)](/img/a6/5c97ef3f34702b83ebf0511501d757.gif)
[shutter] banner carousel component (shutter_wiper plug-in | swiper component)

Opengauss database development and debugging tool guide

I2C 子系统(二):I3C spec

SQL statement

What does "where 1=1" mean
![[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)](/img/6a/ae44ddb090ce6373f04a550a15f973.jpg)
[fluent] JSON model conversion (JSON serialization tool | JSON manual serialization | writing dart model classes according to JSON | online automatic conversion of dart classes according to JSON)

用docker 連接mysql的過程

Add automatic model generation function to hade

Sous - système I2C (IV): débogage I2C

Pytest (6) -fixture (Firmware)
随机推荐
Pytest (6) -fixture (Firmware)
敏捷认证(Professional Scrum Master)模拟练习题-2
Three.js本地环境搭建
What does it mean when lambda is not entered?
I2C subsystem (IV): I2C debug
用docker 連接mysql的過程
Informatics Olympiad one general question bank 1006 a+b questions
Apple releases MacOS 11.6.4 update: mainly security fixes
Introduction to cron expression
Can netstat still play like this?
Xiaodi notes
tensorflow转pytorch笔记;tf.gather_nd(x,y)转pytorch
I2C 子系統(四):I2C debug
[principles of multithreading and high concurrency: 1_cpu multi-level cache model]
敏捷认证(Professional Scrum Master)模拟练习题
模糊查询时报错Parameter index out of range (1 > number of parameters, which is 0)
How to limit the size of the dictionary- How to limit the size of a dictionary?
random shuffle注意
vfork执行时出现Segmentation fault
2022-2028 global splicing display industry research and trend analysis report