清空MSSQL缓存的语句:
DBCC FREEPROCCACHE --清空SQL缓存
DBCC DROPCLEANBUFFERS
DBCC DROPCLEANBUFFERS
查看代码执行时间,占用CPU等的方法
SET STATISTICS io ON
SET STATISTICS time ON
go
---你要测试的sql语句
select * from person where age =(
select max(age) from person )
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
SET STATISTICS time ON
go
---你要测试的sql语句
select * from person where age =(
select max(age) from person )
go
SET STATISTICS profile OFF
SET STATISTICS io OFF
SET STATISTICS time OFF
结果:
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 1 ms.
(9934 row(s) affected)
Table 'person'. Scan count 1, logical reads 9962, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
SQL Server Execution Times:
CPU time = 16 ms, elapsed time = 158 ms.
SQL Server parse and compile time:
CPU time = 0 ms, elapsed time = 1 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 1 ms.
SQL Server Execution Times:
CPU time = 0 ms, elapsed time = 1 ms.