What is "cost"?

  • When the Query Analizer estimates the cost of a query as 5.2837628, is that 5.2837628 of something? Or is it just a number to use for comparison to the cost of other versions of the query?

  • If I remember correctly, cost is the amount of time it took for an operation to run on the specific computer when optimizer costing code was created. It doesn't really have a unit or type.

    Basically it is what your second question asks. You also need to look at other things like IO stats when tuning a query. You can't just use cost.

  • A unitless number that is solely useful in comparing one plan to another. It's also estimated, so can be wrong.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • It's just a number used to perform & report on the math internal to the optimizer. It doesn't mean anything. However, it is represented as if it meant the amount of CPU and IO time spent executing each step. But that's not what it is. Like Gail says, it's just an estimate and can be wrong.

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

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply