SQL monitoring statements

Source: Internet
Author: User


SELECT Top Qs.creation_time
, Last_execution_time
, Total_physical_reads
, Total_logical_reads
, Total_logical_writes,db_name (dbid) dbname
, Execution_count
--, Total_worker_time
, Last_worker_time
--, substring (CONVERT (char), DATEADD (ms,total_worker_time/1000,0), 121), 12,23) total_worker_time
--, Total_elapsed_time
, Last_elapsed_time
, SUBSTRING (CONVERT (char), DATEADD (ms,total_elapsed_time/1000,0), 121), 12,23) total_elapsed_time
--, Total_elapsed_time/execution_count Avg_elapsed_time
, SUBSTRING (CONVERT (char), DATEADD (MS, (Total_elapsed_time/execution_count)/1000,0), 121), 12,23) avg_elapsed_ Time
, SUBSTRING (St.text, (QS.STATEMENT_START_OFFSET/2) + 1,
(Case Statement_end_offset
WHEN-1 then datalength (st.text)
ELSE Qs.statement_end_offset End
-Qs.statement_start_offset)/2) + 1) as Statement_text
From Sys.dm_exec_query_stats as Qs
Cross APPLY Sys.dm_exec_sql_text (qs.sql_handle) St
--order by execution_count desc Schedule Total number of executions
--order by Total_elapsed_time--Total Plan execution duration
ORDER by Last_worker_time desc;--last execution CPU elapsed time

SQL monitoring statements

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.