博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Rebind and Rewind in Execution Plans
阅读量:6153 次
发布时间:2019-06-21

本文共 2322 字,大约阅读时间需要 7 分钟。

http://www.scarydba.com/2011/06/15/rebind-and-rewind-in-execution-plans/

Ever looked at an execution plan? If you answered no, you can’t possibly have ever tried to tune a query, or, you’re doing it wrong. For every one else, no doubt you’ve looked at the tool tips or the property sheets of an operator and you’ve seen the Rebind & Rewind properties and wondered what the heck they mean. Me too.

I learned as much as I could for  and I spent two pages describing it. Then, a little while ago, on the SQL Cruise, someone asked me to describe them and I was flummoxed. Specifically they said the explanation in the book was insufficiently clear, so I promised to put together a blog post on the topic, both to attempt to clarify my explanation and to reacquaint myself with the topic.

These properties reflect the number of times an operator was initialized, or started. It’s that easy for the initial definition. But it gets complicated quickly. Rebind & Rewind are only applicable when dealing with a loop join. They don’t apply to other situations, which is why they’re mostly zero when you see them. They are only applicable to the inner side of the loop.

Not only are Rebind and Rewind only involved with loop joins, but they only apply to certain operators: Nonclustered Index Spool, Remote Query, Row Count Spool, Sort, Table Spool, and Table-valued Function.

The difference between a rebind and rewind has to do with the values that are part of the loop join itself. As those values change, as different data is accessed in the outer part of the loop, you see rebinds. When those values aren’t changed then you’ll see a rewind. You’ll also see that the aggregation of these values is equal to the number of rows in the outer join.

Here’s an example query:

[sourcecode language=”sql”]SELECT  sod.SalesOrderDetailID FROM    Sales.SalesOrderDetail AS sod WHERE   LineTotal < (SELECT AVG(dos.LineTotal) FROM   Sales.SalesOrderDetail AS dos WHERE  dos.ModifiedDate < sod.ModifiedDate )[/sourcecode] It puts out an execution plan that’s pretty ugly, but at least it shoes a table spool in a loop join as you can see: 

If you look at the properties then we can see the values showing multiple rebinds and rewinds that total up to the number of rows in the outer part of the loop.

转载于:https://www.cnblogs.com/qianlixing/p/6065948.html

你可能感兴趣的文章
How to reset XiaoMi bluetooth headphone Youth edition.
查看>>
SEOer 的生涯正式开始
查看>>
CodeForces 348D Turtles(LGV定理)题解
查看>>
返流性食管炎的治疗
查看>>
argumrnts
查看>>
java常用的7大排序算法汇总
查看>>
动归熟手题单
查看>>
压缩算法
查看>>
Http协议详解版本一
查看>>
vuex
查看>>
完整学习git四git对象
查看>>
Bzoj1101: [POI2007]Zap 莫比乌斯反演+整除分块
查看>>
innerHTML outerHTML innerText value 区别
查看>>
ALV打印不显示打印界面的问题
查看>>
octopress github 换电脑 使用
查看>>
angular2 学习笔记 ( animation 动画 )
查看>>
1、 Shiro框架:认证,授权(验权 2. Shiro框架实现权限控制方式:
查看>>
cookie 的使用:打开集团站自动跳转到当前城市所对应的网站,通过改变城市跳转到当前城市所对应的网站...
查看>>
Angular-ui-router入门
查看>>
ngx.re.match
查看>>