Sqlserver find slow SQL statements

Source: Internet
Author: User
Select (total_elapsed_time/execution_count)/1000 n' average time Ms ', total_elapsed_time/1000 n' total time spent Ms', total_worker_time/1000 n' total CPU time Ms ', total_physical_reads n 'Total number of physical reads ', Bytes/execution_count n' total number of logical reads', total_logical_reads n' total number of logical reads ', total_logical_writes n' total number of logical writes ', execution_count n 'execution times', substring (St. text, (Qs. statement_start_offset/2) + 1, (Case statement_end_offsetwhen-1 then datalength (St. text) else Qs. statement_end_offset end-Qs. statement_start_offset)/2) + 1) n'execution statement', creation_time n'statement compilation time', last_execution_time n'last execution time' fromsys. dm_exec_query_stats as QS cross apply sys. dm_exec_ SQL _text (Qs. SQL _handle) stwheresubstring (St. text, (Qs. statement_start_offset/2) + 1, (Case statement_end_offsetwhen-1 then datalength (St. text) else Qs. statement_end_offset end-Qs. statement_start_offset)/2) + 1) Not like '% fetch %' order bytotal_elapsed_time/execution_count DESC;

Go to: http://www.chinaret.com/user/topic_view.aspx? T = 1 & U = Admin & id = 89c86964-7af2-4729-8efc-f8fd3fc3f48a

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.