Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Nasty Table Spool

Author  Topic 

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-08-17 : 14:49:09
I'm hoping anyone can point me in the right direction regarding Table Spools. They seem to be notorious for slow.

I look at the Execution Path:
- Stores the data from the input into a temporary table in order to optimize rewinds.
- Estimated Number of Rows - 1,062.56
- Actual Number of Rows - 20,036,927

The Ouput List columns belong to a Table with 77,000 rows. How/why can SQL Server make a table of 20 million rows when the source table is only 77,000? What is a Rewind? Any ideas who to get rid of the Table Spool?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 14:52:57
Sounds like you've got out-of-date stats. Have you run UPDATE STATS on the table, preferably with FULLSCAN?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-08-17 : 15:14:16
quote:
Originally posted by tkizer

Sounds like you've got out-of-date stats. Have you run UPDATE STATS on the table, preferably with FULLSCAN?

Tara Kizer



Thanks - yes they have been run.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-17 : 15:21:29
The next thing then is to add the right index as your plan is indicating the right index isn't in place. The best index is a covering index, however that isn't always possible to do. Are you able to post the code for us? Is SSMS showing a missing index when you view the plan?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-08-17 : 16:17:19
Yes, it did recommend one. It was a covering one where the index itself already existed - I will try it...
Go to Top of Page
   

- Advertisement -