Measuring Query Performance : “Execution Plan Query Cost” vs “Time Taken”

前端 未结 6 981
天涯浪人
天涯浪人 2020-11-29 20:10

I\'m trying to determine the relative performance of two different queries and have two ways of measuring this available to me:
1. Run both and time each query
2. Ru

6条回答
  •  悲哀的现实
    2020-11-29 21:01

    The profiler trace puts it into perspective.

    • Query A: 1.3 secs CPU, 1.4 secs duration
    • Query B: 2.3 secs CPU, 1.2 secs duration

    Query B is using parallelism: CPU > duration eg the query uses 2 CPUs, average 1.15 secs each

    Query A is probably not: CPU < duration

    This explains cost relative to batch: 17% of the for the simpler, non-parallel query plan.

    The optimiser works out that query B is more expensive and will benefit from parallelism, even though it takes extra effort to do so.

    Remember though, that query B uses 100% of 2 CPUS (so 50% for 4 CPUs) for one second or so. Query A uses 100% of a single CPU for 1.5 seconds.

    The peak for query A is lower, at the expense of increased duration. With one user, who cares? With 100, perhaps it makes a difference...

提交回复
热议问题