当前位置:网站首页>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内部是全表根据主键索引逐行扫描 逐行加锁,事务提交的时候统一释放锁。
边栏推荐
- I2C subsystem (I): I2C spec
- Thunderbolt Chrome extension caused the data returned by the server JS parsing page data exception
- 从C到Capable-----利用指针作为函数参数求字符串是否为回文字符
- Deep reinforcement learning for intelligent transportation systems: a survey paper reading notes
- Pytest (6) -fixture (Firmware)
- Baidu map - surrounding search
- 模糊查詢時報錯Parameter index out of range (1 > number of parameters, which is 0)
- [fluent] future asynchronous programming (introduction | then method | exception capture | async, await keywords | whencomplete method | timeout method)
- Opengauss database development and debugging tool guide
- Source code analysis | layout file loading process
猜你喜欢
random shuffle注意
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc
Practice of traffic recording and playback in vivo
Pytest (6) -fixture (Firmware)
C language beginner level - pointer explanation - paoding jieniu chapter
Classes and objects - initialization and cleanup of objects - constructor call rules
Deep Reinforcement Learning for Intelligent Transportation Systems: A Survey 论文阅读笔记
Add automatic model generation function to hade
Installation and use of memory leak tool VLD
Today, it's time to copy the bottom!
随机推荐
Build a private cloud disk cloudrev
SQL server queries the table structure of the specified table
docker安装redis
Joking about Domain Driven Design (III) -- Dilemma
2022-2028 global splicing display industry research and trend analysis report
Introduction to cron expression
Cancer biopsy instruments and kits - market status and future development trends
A2L file parsing based on CAN bus (2)
[shutter] monitor the transparency gradient of the scrolling action control component (remove the blank of the top status bar | frame layout component | transparency component | monitor the scrolling
Force deduction ----- the minimum path cost in the grid
Your family must be very poor if you fight like this!
HW initial preparation
I2C subsystem (I): I2C spec
HTB-Devel
Use cve-2021-43893 to delete files on the domain controller
Matlab tips (24) RBF, GRNN, PNN neural network
Why choose a frame? What frame to choose
【富瀚6630编码存录像,用rtsp服务器及时间戳同步实现vlc观看录像】
How to limit the size of the dictionary- How to limit the size of a dictionary?
ASP. Net core 6 framework unveiling example demonstration [02]: application development based on routing, MVC and grpc