Query the DMV of the slowest Query

Source: Internet
Author: User

select Top 100
Qs. total_elapsed_time/qs.exe cution_count/1000000.0 as average_seconds,
Qs. total_elapsed_time/1000000.0 as total_seconds,
qs.exe cution_count,
substring (QT. text, Qs. statement_start_offset/2,
(case when Qs. statement_end_offset =-1
then Len (convert (nvarchar (max), QT. text) * 2
else Qs. statement_end_offset end-Qs. statement_start_offset)/2) as individual_query,
O. name as object_name,
db_name (QT. dbid) as database_name
from sys. dm_exec_query_stats QS
Cross apply sys. dm_exec_ SQL _text (Qs. SQL _handle) as QT
left Outer Join sys. objects o on QT. objectid = O. object_id
where QT. dbid = db_id ()

Order by average_seconds DESC;

For more query statements, refer to the original post:

Http://www.sqlservercentral.com/Forums/Topic619606-360-1.aspx

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.