文章出處

禁用nested loop join里的spool

 

轉載自:

https://blogs.msdn.microsoft.com/psssql/2015/12/15/spool-operator-and-trace-flag-8690/

https://answers.sqlperformance.com/questions/698/lazy-spool.html

 

在nested loop join里常常會看到一個spool操作符

這個spool 又名'performance spool',目的是保存被驅動表(外表)排序后的結果,以便后面有相同參數的流能夠繼續使用這個被緩存的結果集。

這樣可以提升一些性能

 

但是有時候spool可能會造成數據傾斜或不均衡,這時候我們可以使用trace flag禁用table spool

USE [AdventureWorks]


SELECT *,COUNT(*) OVER()
from production.[Product] AS p
JOIN production.[ProductSubcategory] AS s
ON s.[ProductCategoryID]=p.[ProductSubcategoryID]
OPTION (QUERYTRACEON 8690)

 

 

本文版權歸作者所有,未經作者同意不得轉載。


文章列表


不含病毒。www.avast.com
文章標籤
全站熱搜
創作者介紹
創作者 AutoPoster 的頭像
AutoPoster

互聯網 - 大數據

AutoPoster 發表在 痞客邦 留言(0) 人氣(9)