Sql server统计查询语句消耗时间


方法1【set statistic 】:

set statistics time on
go
 xxxx
go
set statistics time off

--适用于第一次查找,下一次查找时,易获取缓存 导致查询时间不准确;而且 设置time查找 易受其他因素影响(如系统负载等);

--多次对比查询  建议设置 IO

set statistics IO on
go
 xxxx
go
set statistics IO off

 

 

方法2【getDate()】:

DECLARE @begin dateTime
DECLARE @end dateTime
SET @begin=getdate();
BEGIN
 xxxx
end
set @end=getdate();
SELECT datediff(ms,@begin,@end) as 'Elapsed Time'

方法3【设置Query-Query options】:

 

后两种,未实际验证,见谅。

参考:jcx5083761的专栏  Sql server统计查询语句消耗时间


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM