语句调优基础知识-set statistics time on

时间:2021-05-28 15:29:48

set statistics time on

--清空缓存数据
dbcc dropcleanbuffers
go
--清空缓存计划
dbcc freeproccache
go set statistics time on
go select distinct Productid,unitprice from salesorderdetail_test where Productid=777
go

执行上面代码获取以下信息:

SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 5 ms. (4 row(s) affected) SQL Server Execution Times:
CPU time = 15 ms, elapsed time = 17 ms.

各数据详解:

1.CPU Time

该语句所花纯CPU时间。

2.elapsed Time

该语句总的时间

3.SQL Server parse and compile time

语句的编译时间

4.SQL Server Execution Times

真正的运行时间(包括堵塞,IO等)