Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Estimated number of rows - Temp tables


Estimated number of rows - Temp tables

Author
Message
Arjun Sivadasan
Arjun Sivadasan
SSC-Addicted
SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)SSC-Addicted (448 reputation)

Group: General Forum Members
Points: 448 Visits: 975
Folks, I could not find any material that answers my question.

I have a very long query in which I am using temp table. I use it because otherwise I will have to join with a very huge transaction table multiple number of times. Instead, I filter the rows into a temp table and do the join on this.

Now there is strange thing that I noticed. When I do a join with the temp table the execution plan shows the 'estimated number of rows' as 1 and the 'actual number of rows' as a bigger value.

I have read in SSC that use of UDF will cause this. But in this case I am not using a UDF. Won't the optimizer 'know' the number of rows in the temp table? The temp table is in turn derived from another temp table which is populated from the output of a UDF joined with other tables. Is this the reason?

Please see the attached execution plan. How badly could this aspect affect the performance?
I do not want to post DDL scripts as the query is quite exhaustive [but not tough Smile] and not straightforward.

- confused arjun
Attachments
EP.jpg (19 views, 180.00 KB)
Grant Fritchey
Grant Fritchey
SSCoach
SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)SSCoach (17K reputation)

Group: General Forum Members
Points: 17529 Visits: 32252
Because there is no data in the temp table when it gets created, there are no stats. Without stats, you get an estimate of 1. You can update the stats in the temp table prior to use. That may affect the plan generated.

----------------------------------------------------
The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
Theodore Roosevelt

The Scary DBA
Author of: SQL Server Query Performance Tuning and SQL Server Execution Plans
Product Evangelist for Red Gate Software
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search