概述
通过SQL Profile跟踪SQL,并将跟踪的sql存入表中,运行下列语句就可以获取长事务的id,在EXCEL中通过TransactionID 筛选就可以得到事务的sql和运行时间。
select
TransactionID
[
事务编号
]
,
count ( * ) [ SQL条数 ] ,
datediff (second, min (StartTime), max (EndTime)) [ 事务时间S ]
from yy
where TransactionID is not null
group by TransactionID
order by 3
count ( * ) [ SQL条数 ] ,
datediff (second, min (StartTime), max (EndTime)) [ 事务时间S ]
from yy
where TransactionID is not null
group by TransactionID
order by 3
SQL执行等待间隔时间
SELECT t.TransactionID 事务ID,DATEDIFF(s,t.EndTime,t2.StartTime) [事务SQL间隔时间S],
t.StartTime,t.EndTime FROM
(SELECT TransactionID, DENSE_RANK() OVER (partition BY TransactionID ORDER BY eventsequence) rn,
StartTime,EndTime,TextData
FROM yy
WHERE TransactionID IS NOT NULL) t ,
(SELECT TransactionID, DENSE_RANK() OVER (partition BY TransactionID ORDER BY eventsequence) rn,
StartTime,EndTime,TextData
FROM yy
WHERE TransactionID IS NOT NULL) t2
WHERE t.TransactionID = t2.TransactionID AND t2.rn = t.rn + 1
ORDER BY 2 desc
t.StartTime,t.EndTime FROM
(SELECT TransactionID, DENSE_RANK() OVER (partition BY TransactionID ORDER BY eventsequence) rn,
StartTime,EndTime,TextData
FROM yy
WHERE TransactionID IS NOT NULL) t ,
(SELECT TransactionID, DENSE_RANK() OVER (partition BY TransactionID ORDER BY eventsequence) rn,
StartTime,EndTime,TextData
FROM yy
WHERE TransactionID IS NOT NULL) t2
WHERE t.TransactionID = t2.TransactionID AND t2.rn = t.rn + 1
ORDER BY 2 desc
转载于:https://www.cnblogs.com/zping/archive/2011/03/31/2001105.html
最后
以上就是霸气凉面为你收集整理的查询长事务和SQL执行等待间隔时间的全部内容,希望文章能够帮你解决查询长事务和SQL执行等待间隔时间所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复