当前位置:网站首页>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内部是全表根据主键索引逐行扫描 逐行加锁,事务提交的时候统一释放锁。
边栏推荐
- 迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
- 敏捷认证(Professional Scrum Master)模拟练习题
- I2C 子系统(四):I2C debug
- Kubernetes family container housekeeper pod online Q & A?
- Notifydatasetchanged not applicable to recyclerview - notifydatasetchanged not working on recyclerview
- vfork执行时出现Segmentation fault
- I2C 子系统(一):I2C spec
- I2C 子系统(三):I2C Driver
- Super easy to use logzero
- Tensorflow to pytorch notes; tf. gather_ Nd (x, y) to pytorch
猜你喜欢
随机推荐
Variable declarations following if statements
Joking about Domain Driven Design (III) -- Dilemma
The core idea of performance optimization, dry goods sharing
Add automatic model generation function to hade
后管中编辑与预览获取表单的值写法
Installation and use of memory leak tool VLD
ComponentScan和ComponentScans的区别
[C language] MD5 encryption for account password
复选框的使用:全选,全不选,选一部分
Strategy application of Dameng database
[C语言]给账号密码进行MD5加密
Segmentation fault occurs during VFORK execution
力扣------网格中的最小路径代价
Kubernetes cluster log and efk architecture log scheme
Your family must be very poor if you fight like this!
Source code analysis | layout file loading process
[fluent] listview list (map method description of list set | vertical list | horizontal list | code example)
SQL server queries the table structure of the specified table
左连接,内连接
Notifydatasetchanged not applicable to recyclerview - notifydatasetchanged not working on recyclerview









