Estimated Operator Cost Calculation

The only way to properly answer that question is to fire up the debugger and see what choices were made by the optimizer along the way. The costs are not only IO and CPU. There are additional costs associated with a given operator that are reflected in the total cost, but are not reflected in the IO and CPU cost estimates. You can read more about some of the additional costs in this excellent article by Paul White.

I don't have a precise answer to your question (I've not doubt, Paul would). However, I'm willing to take a guess. What you're seeing is added overhead for the operation as determined by the optimizer above and beyond what it is displaying as the overhead for the IO and CPU as determined by the estimated rows, etc.. I believe it's a calculation based on what would necessary in terms of IO to create the table and store the 246.492 rows * 9b worth of data on each that is calculated as being in the INSERT statement. 246.492 * 9 / 1024 = 2.1664 is less than an 8k page. However, we have to create at least a page, so when you calculate 8 * the cost of .01, it puts us just a little above the estimated .073832. That's my guess, and it is a guess. However, I do know that there is overhead in the costs that isn't displayed by the strict addition of CPU + IO in all cases.


Grant, I believe a coworker (Dennis Rogers) and I have answered the question. Here appears the definitive formula that SSMS uses to calc the operator cost and the cost %.

Estimated Operator Cost == @EstimatedTotalSubtreeCost - Sum(Immediate Children@EstimatedTotalSubtreeCost)

Estimated Operator Cost Percent = Estimated Operator Cost / StmtSimple@StatementSubTreeCost * 100

I have tested this out with several plans and this appears to be spot on.

To represent the above calculation as xpath it turns into:

@EstimatedTotalSubtreeCost - sum(./descendant::s:RelOp[1]/../s:RelOp/@EstimatedTotalSubtreeCost) 

The sum finds the first descendant that is of type RelOp, then backs up one level, and gets all of the RelOps at that level and extracts their EstimatedTotalSubtreeCost.