当前位置: 数据库>sqlserver
在SQLServer上查看SQL语句的执行时间的方法
来源: 互联网 发布时间:2014-09-05
本文导语: 1:下面这种是比较简单的查询方法,通过查询前的时间和查询后的时间差来计算的 代码如下: declare @begin_date datetime declare @end_date datetime select @begin_date = getdate() select @end_date = getdate() select datediff(ms,@begin_date,@end_date) as '用时/毫...
1:下面这种是比较简单的查询方法,通过查询前的时间和查询后的时间差来计算的
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
2:下面这种方法比较全面,将执行每个语句时采取的步骤作为行集返回,通过层次结构树的形式展示出来
set statistics profile on
set statistics io on
set statistics time on
go
go
set statistics profile off
set statistics io off
set statistics time off
代码如下:
declare @begin_date datetime
declare @end_date datetime
select @begin_date = getdate()
select @end_date = getdate()
select datediff(ms,@begin_date,@end_date) as '用时/毫秒'
2:下面这种方法比较全面,将执行每个语句时采取的步骤作为行集返回,通过层次结构树的形式展示出来
代码如下:
set statistics profile on
set statistics io on
set statistics time on
go
go
set statistics profile off
set statistics io off
set statistics time off