views:

31

answers:

2

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?

+4  A: 

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)
Graphain
+3  A: 

As long as there is only one query in your batch, it's cost relative to the batch will always be 100%. If you have more than one query in the batch, they will add up to 100%.

The percentage only shows how queries in the batch relate to each other, it's not an absolute measure of the cost. Even if the cost is minimal, it's still always 100%.

Guffa