简体   繁体   English

SQL Server Profiler

[英]SQL Server Profiler

When you use SQL Server profiler What's difference between Duration and CPU? 使用SQL Server分析器时持续时间和CPU之间有什么区别? I know by default both were shown as in MilliSeconds and CPU is amount of CPU time it took to run the query while duration is more like amount of time it took query to return any data. 我知道默认情况下两者都显示为MilliSeconds,CPU是运行查询所花费的CPU时间量,而持续时间更像是查询返回任何数据所花费的时间。

Based on my understanding if there is any blocking etc. your CPU time could be less but duration could be higher. 根据我的理解,如果有任何阻塞等,你的CPU时间可能会更少,但持续时间可能会更长。

Can anyone proivde more insight? 任何人都可以提供更多洞察力吗? Scramble through the BOL but hard to find subtle differences. 争夺BOL但很难找到微妙的差异。

The CPU time represents time consumed actively (not suspended) by the request/statement (depending on what event you're monitoring) on all CPUs . CPU时间表示所有CPU上的请求/语句(取决于您正在监视的事件)主动(未挂起)消耗的时间。 For single threaded queries this will always be less or equal than the elapsed time (duration = wall clock time). 对于单线程查询,这将始终小于或等于经过的时间(持续时间=挂钟时间)。 But for parallel queries the CPU time can exceed the elapsed time because it adds up the CPU time from several CPUs. 但对于并行查询,CPU时间可能会超过经过的时间,因为它会累计来自多个CPU的CPU时间。

In general this distinction between elapsed and CPU time applies everywhere in SQL Server, from SET STATISTICS TIME ON output, to DMVs like sys.dm_exec_query_stats (where CPU time is called worker_time ) or sys.dm_exec_requests (again named cpu_time in this DMV). 通常,经过时间和CPU时间之间的区别适用于SQL Server中的任何位置,从SET STATISTICS TIME ON输出到DMV,如sys.dm_exec_query_stats (其中CPU时间称为worker_time )或sys.dm_exec_requests (在此DMV中再次命名为cpu_time )。

Duration can include wait time, I/O, data transfer time, etc. CPU is just the time the CPU spent. 持续时间可以包括等待时间,I / O,数据传输时间等CPU 只是 CPU所花费的时间。 If your query is CPU-bound, it will be a lot closer than if it is I/O- or memory-bound. 如果您的查询受CPU约束,那么它将比I / O或内存限制更接近。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM