Use SQL profile to track SQL statements and store the tracked SQL statements into tables. Run the following statements to obtain the ID of a long transaction, you can use transactionid filtering in Excel to obtain the SQL statement and running time of the transaction.
Select transactionid [Transaction id],
Count (*) [number of SQL statements],
Datediff (second, min (starttime), max (endtime) [transaction time s]
From YY
Where transactionid is not null
Group by transactionid
Order by 3
SQL Execution wait Interval
Select T. transactionid: Transaction ID, datediff (S, T. endtime, t2.starttime) [Transaction SQL interval 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