Interval between querying long transactions and SQL Execution

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.