View performance-poor statements in SQL Server 2008

Source: Internet
Author: User
Tags execution

Use this statement frequently to view poorly-performing SQL statements:

SELECT creation_time N ' statement compile time '

, Last_execution_time N ' last Execution time '

, total_physical_reads N ' total number of physical reads '

, Total_logical_reads/execution_count N ' per logical read times '

, the total number of total_logical_reads N ' logical reads '

, Total_logical_writes N ' logical write total number of times '

, Execution_count N ' execution times '

, total_worker_time/1000 N ' CPU total time MS '

, total_elapsed_time/1000 N ' total time spent MS '

, (total_elapsed_time/execution_count)/1000 N ' Average Time MS '

, 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) N ' execute statement '

From Sys.dm_exec_query_stats as Qs

CROSS APPLY sys.dm_exec_sql_text (qs.sql_handle) St

where 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) Not like '% fetch% '

and qs.execution_count>10000 and

(Total_elapsed_time/execution_count)/1000>150

Order by Total_elapsed_time/execution_count DESC;

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

Related Article

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.