Slow query statement

Source: Internet
Author: User
Tags high cpu usage

Select
C.last_execution_time,c.exe cution_count, C. total_logical_reads, C. total_logical_writes, C. total_elapsed_time, C. last_elapsed_time,
Q. [text]
From
(Select top 50 Qs .*
From SYS. dm_exec_query_stats Qs
Order by QS. total_worker_time DESC) as C
Cross apply SYS. dm_exec_ SQL _text (plan_handle) as Q
Order by C. total_worker_time DESC

Queries statements with high CPU usage

Select top 10
Total_worker_time/execution_count as avg_cpu_cost, plan_handle,
Execution_count,
(Select substring (text, statement_start_offset/2 + 1,
(Case when statement_end_offset =-1
Then Len (convert (nvarchar (max), text) * 2
Else statement_end_offset
End-statement_start_offset)/2)
From SYS. dm_exec_ SQL _text (SQL _handle) as query_text
From SYS. dm_exec_query_stats
Order by [avg_cpu_cost] 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.