Query high-consumption SQL statements

Source: Internet
Author: User

Query high-consumption SQL statements

High IO consumption:

Select top 10
[Average IO] = (total_logical_reads + total_logical_writes)/qs.exe cution_count
, [Total IO] = (total_logical_reads + total_logical_writes)
, [Execution count] = qs.exe cution_count
, [Individual Query] = 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)
, [Parent Query] = qt. text
, DatabaseName = DB_NAME (qt. dbid)
FROM sys. dm_exec_query_stats qs
Cross apply sys. dm_exec_ SQL _text (qs. SQL _handle) as qt
Order by [Average IO] DESC;

High CPU consumption:

Select top 10
[Average CPU used] = total_worker_time/qs.exe cution_count
, [Total CPU used] = total_worker_time
, [Execution count] = qs.exe cution_count
, [Individual Query] = 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)
, [Parent Query] = qt. text
, DatabaseName = DB_NAME (qt. dbid)
FROM sys. dm_exec_query_stats qs
Cross apply sys. dm_exec_ SQL _text (qs. SQL _handle) as qt
Order by [Average CPU used] 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.