Way to compare two different queries that produce same results and see performance costs for both?

  • So we have two queries, both execute at the same real world speed.

    However, I'm betting query 2 is much more efficient with large record sets than query 1.

    Is there a way to get some sort of magic "cost value" out of the execute plan?

    If we know that both return the same data, then can I say "query 1 costs 300" and "query 2 costs 75"... something like that?

    Cost of reads, cost of writes, costs of CPU, etc...?

    Maybe Profiler could consume both and compare/contrast?

    Thanks!

  • Use the SET commands. STATISTICS IO ON, compare reads/writes.

    you could use Trace/Profiler as well.

    Less reads, CPU might be the way to go.

  • In profiler I see reads and duration.

    But CPU is still 0, is there any way to get a closer look at that?

    Since the queries are not taxing the system, can I get any sort of look at the amount of calculations being done?

    The one I thought would be faster was faster (120 vs 128) and it had approx half as many reads.

    But I was wondering if there is anything else I can use to benchmark this.... other than making it read from a massively larger table?

    Thanks again!

    EDIT: I'm an idiot and clicked REPORT and not reply... sorry about that.... (shame) :blush:

  • No, you need to grow the tables if they aren't registering in the counters.

  • Although, usually, half as many reads is pretty much the end of the story. I'd check the execution plan though, see what differences there are there.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • The execution plan for the slower query is broken over 3 or 5 individual queries, so that makes it harder for me to compare.

    HOWEVER, I also need to read up on how to properly understand execution plans.

    Also, is that a Starfury?

    Babylon 5 was a wonderful show, best plot arc on TV ever so far as I am concerned. 🙂

  • Yeah, you can't really directly compare one execution plan to other as such, you just evaluate each one to see if there are issues.

    Yes, it's a Star Fury. B-5 is definately one of those great shows, although it's starting to look a little aged.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Yeah, but for the shoe string budget they had, and the really underpowered computers (even for that time from what I understand) they did an amazing job!

    I was really sad that "The Lost Tales" didn't take off and was sort of killed by the studios...

    Also the creator of B5 (JMS) was set to do a Zombie film, and the script got leaked. Apparently various film critics got a hold of the leaked copy and said it would have been the first zombie flick to ever have an actual shot at winning an academy award!

    Then the studios brought in someone else to re-edit the script to make it more "suitable for the audience"... ugh.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply