-244 Could not do a physical-order read to fetch next row 产生的根本原因

148 篇文章 7 订阅
52 篇文章 1 订阅

Norfolk Door Latch, courtesy of Morris L. Hallowell IV

            Without the index every update and delete has to scan the entire table looking for matching rows to update/delete. Each row as it is examined has to be locked, dirty read or no dirty read, for a fraction of a second. As multiple scans zip through the table it is inevitable that one or more will encounter a row that’s locked. If multiple sessions have to delete multiple rows on the same page they will all have to latch the same page in the cache and so will queue up behind one another each holding a lock on a different row on that one page. They will single thread on the cache page latch and on the LRU latch needed to move the page from the clean part of the LRU queue to the dirty part or from the middle of the dirty queue to the most recently used end of the dirty queue. Those latches are exclusive even under dirty read isolation to maintain the integrity of the cache page and the LRU queues. All that time the N+1st session is waiting for a row lock on one of the rows in that frozen page to clear so it can read that row and continue its scan. That row lock cannot be satisfied, even under dirty read, because the cache page itself is latched. Eventually, sometimes, the last waiter times out before it gets access to the locks or latches that it needs.

            The index almost eliminates the problem because that waiter who doesn’t need to update another row on the same cache page is able to go around the page locks because it is scanning the index instead which is not being locked and which this N+1st session does not have to acquire a lock for.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

请叫我曾阿牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值