Wednesday, March 7, 2012

Realtive query cost in the execution plan

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.examnotes.net ***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:
> 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.examnotes.net ***|||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.examnotes.net ***|||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:
> 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.examnotes.net ***

No comments:

Post a Comment