You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -5745,6 +5744,31 @@ MySQL Server 是多线程结构,包括后台线程和客户服务线程。多
5745
5744
5746
5745
5747
5746
5747
+
***
5748
+
5749
+
5750
+
5751
+
#### 加锁分析
5752
+
5753
+
InnoDB 存储引擎支持事务,所以加锁分析是基于该存储引擎
5754
+
5755
+
* Read Uncommitted 级别,任何操作都不会加锁
5756
+
5757
+
* Read Committed 级别,增删改操作会加写锁(行锁),读操作不加锁
5758
+
5759
+
MySQL 做了优化,在 Server 层过滤条件时发现不满足的记录会调用 unlock_row 方法释放该记录的行锁,保证最后只有满足条件的记录加锁,但是扫表过程中每条记录的**加锁操作不能省略**。所以对数据量很大的表做批量修改时,如果无法使用相应的索引,需要在Server 过滤数据时就会特别慢,出现虽然没有修改某些行的数据,但是还是被锁住了的现象,这种情况同样适用于 RR
0 commit comments