当前位置:网站首页>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内部是全表根据主键索引逐行扫描 逐行加锁,事务提交的时候统一释放锁。
边栏推荐
- Add automatic model generation function to hade
- Add MDF database file to SQL Server database, and the error is reported
- Counter统计数量后,如何返回有序的key
- TCP handshake three times and wave four times. Why does TCP need handshake three times and wave four times? TCP connection establishes a failure processing mechanism
- Kubernetes family container housekeeper pod online Q & A?
- docker安装redis
- Opengauss database development and debugging tool guide
- 【Flutter】shared_ Preferences local storage (introduction | install the shared_preferences plug-in | use the shared_preferences process)
- SQL statement
- Le processus de connexion mysql avec docker
猜你喜欢

Le processus de connexion mysql avec docker

HTB-Devel

Distributed transaction

Classes and objects - initialization and cleanup of objects - constructor call rules

Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 2)

Kubernetes cluster log and efk architecture log scheme

Installation and use of memory leak tool VLD

用docker 連接mysql的過程

C语言初阶-指针详解-庖丁解牛篇

Joking about Domain Driven Design (III) -- Dilemma
随机推荐
JS finds all the parent nodes or child nodes under a node according to the tree structure
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)
What does it mean when lambda is not entered?
HW-初始准备
I2C subsystem (IV): I2C debug
Matlab tips (24) RBF, GRNN, PNN neural network
[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)
vfork执行时出现Segmentation fault
Installation and use of memory leak tool VLD
模糊查询时报错Parameter index out of range (1 > number of parameters, which is 0)
迅雷chrome扩展插件造成服务器返回的数据js解析页面数据异常
Sqlserver row to column pivot
Kubernetes cluster log and efk architecture log scheme
Yiwen takes you to know ZigBee
Check log4j problems using stain analysis
tensor中的append应该如何实现
Your family must be very poor if you fight like this!
From C to capable -- use the pointer as a function parameter to find out whether the string is a palindrome character
Variable declarations following if statements
[flutter] example of asynchronous programming code between future and futurebuilder (futurebuilder constructor setting | handling flutter Chinese garbled | complete code example)