Query cost relative to batch is 100%

chobo picture chobo · Jul 7, 2010 · Viewed 22.6k times · Source

I'm not sure sure how to interpret this, but all the queries I run in sql server 2005 have a "query cost (relative to batch)" of 100%. Is there any way to reduce the cost?

Answer

Matt Mitchell picture Matt Mitchell · Jul 7, 2010

If your batch (what you are executing within a given call) has one query then relative to that batch that query takes up 100% as it is the only query within that batch.

I.e.:

BEGIN
  SELECT * FROM table -- Will be 100% of batch
END

BEGIN
  SELECT * FROM table -- Will be 50% of batch
  SELECT * FROM table -- Will be 50% of batch
END

SELECT * FROM table -- Will be 100% of batch (implicit begin/end around it)