SQL Server finds execution slow

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 physical reads '
, Total_logical_reads/execution_ Count n ' per logical read '
, total_logical_reads n ' logical read total number '
, total_logical_writes n ' logical write total number '
, execution_count n ' execution count '
, 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 '
, St.text
, Creation_time N ' statement compilation time '
, Last_execution_time N ' last execution time '
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% '
ORDER by Total_elapsed_time/execution_count DESC

SQL Server found a slow execution of the SQL

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.