views:

54

answers:

2
+1  Q: 

sql server tuning

how does the query optimizer determine estimated row size when we execute any query?

A: 

Query optimizers will inspect the current data and assume worst case if no data is availble. Some database vendors do an average case but without data it probably is better to just asume the worse. If you are talking about estimating the number of returned rows that is completely another story.

ojblass
+2  A: 

SQL Server uses statistics and the current data set to do this analysis. Here is a very detailed link covering the data SQL 2008's query optimizer uses to calculate this for you.

Also, this link goes into more detail as to exactly how the optimizer generates a query plan with an internal estimate of rows.

mwigdahl
thank you very much
Anoop