HiveBrain v1.2.0
Get Started
← Back to all entries
principlesqlModerate

Statistics: CPU Time vs Elapsed Time. What is more important?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
elapsedwhatmoretimestatisticsimportantcpu

Problem

When performance tuning, what is more important:

  • CPU time or elapsed time?



  • Are there scenarios where one of them is more important than the other?



An example: while performance tuning the CPU time will reduce by ~38% but the Elapsed Time increases by ~22%. Is this an improvement?

Solution

CPU Time is the quantity of processor time taken by the process. This does not indicate duration. "Elapsed Time" represents the total duration of the task. If a given task uses a parallelism of 8 (i.e. 8 threads), and each thread is used at a rate of 100% over the entire duration of the task, CPU time could be 8000ms, while Elapsed Time would only be 1000ms.

Therefore, shorter "Elapsed Time" indicates faster response time.

You may want shorter CPU time and longer elapsed time if you are concerned about CPU pressure, and don't care about user experience.

You may accept longer CPU time if that results in a drop in elapsed time, since that might indicate the user is waiting less, at the expense of higher CPU utilization.

Arguably, the more important metric for query tuning would be wait times.

Context

StackExchange Database Administrators Q#161015, answer score: 19

Revisions (0)

No revisions yet.