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统计查询语句消耗时间

posted @ 2016-07-14 16:35  Twang  阅读(3147)  评论(0编辑  收藏  举报