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?
The cost relative to the batch is just comparing the cost estimates of each statement within the batch. That's all. It's not itself a measure as much as it's a comparison of other measures. As a comparison, it's useful.
To estimate the cost of a query evaluation plan, we use the number of blocks transferred from the disk, and the number of disks seeks. Suppose the disk has an average block access time of ts seconds and takes an average of tT seconds to transfer x data blocks.
Every query has a cost, which SQL Server records in the Execution Plan. This is the cost assigned to the query by the optimizer. While troubleshooting query performance in SQL Server, it is crucial to be are aware of this cost. In many cases, queries are sorting and hashing as a result of internal operations.
Query Cost is a cost in which the enhancer considers what amount of time your query will require (comparative with absolute clump time).
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)
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%.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With