1.测试sql语句执行时间的方法,获得时间差
declare
@end_date
datetime
select
@begin_date =
getdate()
--要执行的sql语句
select
@end_date =
getdate()
select
datediff(ms,@begin_date,@end_date)
as
‘用时/毫秒‘
2.下面这种方法比较全面,将执行每个语句时采取的步骤作为行集返回,通过层次结构树的形式展示出来,输出中包含的列:
SET
STATISTICS
io
ON
SET
STATISTICS
time
ON
go
--要执行的sql语句
go
SET
STATISTICS
profile
OFF
SET
STATISTICS
io
OFF
SET
STATISTICS
time
OFF
sql语句的效率测试,码迷,mamicode.com
时间: 2024-10-29 19:11:29