查询分析工具

时间:2012-01-19 11:48:13

标签: jquery optimization

假设查询中有10个连接,我想找到哪个连接需要很长时间来获取数据是否有任何工具可以获取该报告?

1 个答案:

答案 0 :(得分:1)

1)一种方法是保存查询之前和之后的时间并进行计算 区别,如下:

DECLARE @start_time DATETIME, @end_time DATETIME
SET @start_time = CURRENT_TIMESTAMP

-- query goes here

SET @end_time = CURRENT_TIMESTAMP
SELECT DATEDIFF(ms, @start_time, @end_time)

You can also use something like this to see the execution time in the
Messages tab:

SET STATISTICS TIME ON

-- query goes here

SET STATISTICS TIME OFF

2)运行SQL事件探查器跟踪

3)分析执行计划