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 the book on execution plans 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.

Rebind and Rewind in Execution Plans的更多相关文章

  1. 简译《Dissecting SQL Server Execution Plans》——连载总入口

    转载请注明出处 由于工作及学习需要,最近看了一下<Dissecting SQL Server Execution Plans>,这是少有的专门描述执行计划的优秀书籍,为了快速查找并供入门同 ...

  2. 《Pro SQL Server Internals, 2nd edition》的CHAPTER 3 Statistics中的Introduction to SQL Server Statistics、Statistics and Execution Plans、Statistics Maintenance(译)

    <Pro SQL Server Internals> 作者: Dmitri Korotkevitch 出版社: Apress出版年: 2016-12-29页数: 804定价: USD 59 ...

  3. Oracle SQL explain/execution Plan

    From http://blog.csdn.net/wujiandao/article/details/6621073 1. Four ways to get execution plan(anyti ...

  4. Execution Plan 执行计划介绍

    后面的练习中需要下载 Demo 数据库, 有很多不同的版本, 可以根据个人需要下载.  下载地址 -http://msftdbprodsamples.codeplex.com/ 1. 什么是执行计划 ...

  5. sql是如何执行一个查询的!

    引用自:http://rusanu.com/2013/08/01/understanding-how-sql-server-executes-a-query/ Understanding how SQ ...

  6. Understanding how SQL Server executes a query

    https://www.codeproject.com/Articles/630346/Understanding-how-SQL-Server-executes-a-query https://ww ...

  7. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  8. Microsoft SQL Server Version List(SQL Server 版本)

    原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Servic ...

  9. SqlServer 版本号

    RTM (no SP) SP1 SP2 SP3 SP4 SQL Server 2014      codename Hekaton  12.00.2000.8 SQL Server 2012      ...

随机推荐

  1. sgu - 269 - Rooks

    题意:给出一个n行的棋盘,每行的长度任意,问在该棋盘中放k个车(不能同行或者同列)有多少种放法(n <= 250, 每行的长度 <= 250). 题目链接:http://acm.sgu.r ...

  2. cocos2d-x 仿真树叶飘落效果的实现

    转自:http://blog.csdn.net/ufolr/article/details/7624851 最近项目中需要一个落叶的效果,本来想用粒子特效来实现,但是几经调试,虽然调出了落叶的效果,但 ...

  3. skyline TerraExplorer fly设置相对路径的方法

    软件环境:TerraExplorer Pro(以下简称TEP)6.5 在TEP中,对于本地(非网络)文件路径,默认都是绝对路径,在移动数据时非常麻烦,以下是本人总结出一些设置相对路径的规则 假设fly ...

  4. JellyViewPager

    https://github.com/jfeinstein10/JazzyViewPager https://github.com/chiemy/JellyViewPager JellyViewPag ...

  5. JavaEE系列之(一)JSP基础知识详解

    一.JSP基础语法     1.JSP简介        JSP(Java Server Pages),其根本是一个简化的Servlet设计,它实现了在Java中使用HTML标签.JSP是一种动态网页 ...

  6. 使用proguard混淆android代码

    当前是有些工具比方apktool,dextojar等是能够对我们android安装包进行反编译,获得源代码的.为了降低被别人破解,导致源代码泄露,程序被别人盗代替码,等等.我们须要对代码进行混淆,an ...

  7. textarea 中的换行符问题

    下面是我对这个问题的解决过程,最后算是完全搞懂了,真是阴沟里险些翻船 1.必须知道textarea中的换行符是 \n  (个人检测发现按回车键是\n,好像在linux下是\r\n) 2.用nl2br之 ...

  8. Android XML文件布局各个属性详解

    第一常用类:属性值为true或false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 android: ...

  9. 解决JSP页面图片缓存问题

    <% String imagepath="D:\\work\\dbUpdate\\src\\main\\webapp\\newyzm.png"; %> <img ...

  10. oracle数据库元数据SQL查询

    oracle数据库经典SQL查询 .查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_size from ...