March 5, 2012 at 12:33 pm
So I ran a query with the time statistics on and got a result that puzzled my intuitive (not taught) understanding of these statistics. The CPU Time was 16ms and elapsed time was 9ms. I had always assumed that CPU time was included in elapsed time. So, not being able to find a definition of what is actually being measured, I have come to the experts. Anyone?
Jared
CE - Microsoft
March 5, 2012 at 1:49 pm
CPU time = total time spent by CPU processing the query. Elapsed time = total time between query starting and query completing.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 5, 2012 at 1:55 pm
Gail is correct in his definition. To elaborate a bit: If you use 4 cores for 2 seconds, you'll see a CPU time of 8s whereas the elapsed time is 2s. What I've found, is that in general the CPU time increases as the level of parallelism (number of cores used) increases. So, a task that uses 8 seconds of CPU time on a single core, may use four cores for 2.5 seconds, a total CPU time of 10 seconds. So, the CPU load of the server increases, but locks are held for a shorter period of time.
March 5, 2012 at 2:07 pm
Thanks for the quick responses. So basically, the maximum CPU time is a function of #cores/cpu * #cpus * elapsed time. Of course it can be lower than this, but should never be greater?
Jared
CE - Microsoft
March 5, 2012 at 2:22 pm
Why complicate matters? It's the number of cores available to SQL Server, SQL doesn't care about the number of sockets.
Also consider measuring inaccuracies.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 5, 2012 at 2:24 pm
GilaMonster (3/5/2012)
Why complicate matters? It's the number of cores available to SQL Server, SQL doesn't care about the number of sockets.Also consider measuring inaccuracies.
Good point 🙂 Thanks!
Jared
CE - Microsoft
March 5, 2012 at 4:52 pm
March 7, 2012 at 9:11 am
I'd also recommend using SQL Profiler (SQL:BatchCompleted event) instead of SET STATISTICS * for measuring reads, writes, duration, and CPU time; Gail's Functions, IO statistics and the Execution plan[/url] article shows one solid reason for using Profiler rather than SET STATISTICS IO, at least.
Also consider your system; on at least some systems, IO is more important than CPU time (spindle contention).
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply