暂无图片
mysql中rc隔离下,select for update和update的不同?
我来答
分享
暂无图片 匿名用户
mysql中rc隔离下,select for update和update的不同?

表abc (id  primary key, cid int)

有2列

表里的数据有2条


1 , 100

2, 200


begin;select * from  abc where cid=100 for update  ;

begin;select * from  abc where cid=200 for update  ; 

在rc 下面,上面for update这两个发生了等待

begin;update  abc set cid=cid+1  where cid=100;

begin;update  abc set cid=cid+1  where cid=200;

这2个update没有等待,能执行成功

请问这个里面的原因是啥呢?谁帮忙详细给讲一下

我来答
添加附件
收藏
分享
问题补充
2条回答
默认
最新
everything

explain 看看

暂无图片 评论
暂无图片 有用 1
张sir

select for update 执行计划走的全表扫描,mysql就会锁全表

update 走的是主键索引,在rc模式下,就锁单个记录。

暂无图片 评论
暂无图片 有用 1
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏