Home All Groups Group Topic Archive Search About

Realtive query cost in the execution plan

Author
9 Dec 2005 4:21 PM
mEmENT0m0RI
Hello everyone!

I have a general question about measuring query cost while tuning
queries. If I put both queries (the old one and the modified one) into
the same batch, can I then use the query cost (relative to the batch)
percentage number as a reliable way of measuring whether the performance
has improved?

I would also appreciate any links to the good articles on this matter.

Thank you,
Igor


*** Sent via Developersdex http://www.developersdex.com ***

Author
9 Dec 2005 4:42 PM
Trey Walpole
that's a good way to start - if it really unbalanced (e.g., version 1 is
90% of the total cost), then i've typically satisfied as to which is best.

however, i've found the most accurate way to measure it is to get the
actual timings over at least 10 runs. if it's a really long query, this
may not be totally feasible

e.g.

declare @x datetime

set @x = getdate()
-- run version 1
select datediff(ms, @x, getdate()) as Version1_timing

set @x = getdate()
-- run version 2
select datediff(ms, @x, getdate()) as Version2_timing

mEmENT0m0RI wrote:
Show quote
> Hello everyone!
>
> I have a general question about measuring query cost while tuning
> queries. If I put both queries (the old one and the modified one) into
> the same batch, can I then use the query cost (relative to the batch)
> percentage number as a reliable way of measuring whether the performance
> has improved?
>
> I would also appreciate any links to the good articles on this matter.
>
> Thank you,
> Igor
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
Author
9 Dec 2005 4:55 PM
mEmENT0m0RI
Trey,
Thanks for your reply.

How about measuring the absolute query cost? Let's say I've added some
indexes and want to see the performance  difference?


*** Sent via Developersdex http://www.developersdex.com ***
Author
9 Dec 2005 5:06 PM
Trey Walpole
by "absolute" do you mean what it actually uses rather than the estimate?
if so, run the queries again, but with the Show Execution Plan option
on. (CTRL-K is the shortcut).
this will show the actual query plan used - btw: you'll have to use this
option rather than the estimated query plan if temp tables are involved.

mEmENT0m0RI wrote:
Show quote
> Trey,
> Thanks for your reply.
>
> How about measuring the absolute query cost? Let's say I've added some
> indexes and want to see the performance  difference?
>
>
> *** Sent via Developersdex http://www.developersdex.com ***

AddThis Social Bookmark Button