Query cost relative to batch is 100%

℡╲_俬逩灬. 提交于 2021-01-26 03:13:36

问题


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?


回答1:


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)



回答2:


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%.



来源:https://stackoverflow.com/questions/3191356/query-cost-relative-to-batch-is-100

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!