Quantcast
Channel: SQL Server – Danny Ravid MS-SQL & BI Practice Leader, GlassHouse
Viewing all articles
Browse latest Browse all 9

what “estimated subtree cost = 1” means ? or a great SQL server history story….

$
0
0

a lot of my student’s ask me when we talk about query plans and and we are hovering over a graphical plan in SSMS like this one :

image

the question is,what does the estimated subtree cost = 0.6237 mean ? is it 0.6273 seconds,milliseconds,heart beats ? I can quote BOL and say “The total cost to the query optimizer for executing this operation and all operations preceding it in the same subtree.”

which basically brings us back to the first question ….:-)

well the answer I give students is that a cost is a relative number to other cost of other queries on the SAME MACHINE,if a cost of a query on the same machine is SMALLER the a cost of second query on the same machine ,the smaller cost query will usually run faster then the more “expensive” one,this numbers also drives us in query tuning where we always seek to have the lowest cost possible for our queries ,this will usually produce faster execution times (why usually and not always,because there are extreme cases and bugs when things don’t work as expected…. :-() .

ok ,going back to the original question ,how does the cost is determined ? or what “estimated subtree cost = 1 means ?

I want to share with you a story I heard from Lubor Kollar who was the Program Manager for the Query Optimizer Team of SQL Server ,and now he is leading the SQL Server Customer Advisory Team (http://blogs.msdn.com/sqlcat/default.aspx) which is part of the product group.

the story goes that when the new query optimizer was developed for SQL server 7.0  in the Query Optimizer team there was a programmer called nick (I am sorry but I do not know his last name) ,he was responsible for calculating query costs  (among other things…)  ,and he had to decide how to generate the cost number for a query ,so he decided that if query runs for 1 second on his own pc the cost will be ….. 1 ,so we can finally answer the question  what is “estimated subtree cost = 1” means,it means ladies and gentleman  that it runs for 1 second on nick’s machine!

sometime ago Lubor Kollar sent me a picture of nick’s machine ,and here it is :

nick_pc

rumor’s are saying that this pc is now stored in Lubor Kollar’s garage…..

if you guys are interested more about SQL server history here is a couple of good link’s.

Enjoy

Danny

http://insidesqlserver.com/companion/History%20of%20SQL%20Server.pdf

http://blogs.msdn.com/euanga/archive/2006/05/23/597677.aspx


Viewing all articles
Browse latest Browse all 9

Trending Articles