假设一个查询中有10个连接,我想找出哪个连接花费了很长时间来获取数据,有没有什么工具可以获取报告?
发布于 2012-01-19 19:52:51
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 OFF2)运行SQL事件探查器跟踪
3)分析执行计划
https://stackoverflow.com/questions/8925518
复制相似问题