SQL Server Performance Analysis--execution of SQL times and number of logical times

Source: Internet
Author: User
Tags what sql

Currently in a project optimization, want to analyze SQL Server system performance through the database layer, check the online code, modify the title and DMVs code, the following code can be used to analyze the system after a period of time, those statements are system busy SQL statement. As a reference.

Alternative use:

Once in the analysis of a reconciliation function, look at the system code, read half a day, write too irregular, and do not write comments, can not understand. Finally, with the following tips, and share with you:

When measuring the function, the following command clears the SQL Server cache:

DBCC Freeproccache

After clicking on a button and executing the following statement, you can know what SQL and how many times the system is running, and the main slow statements are those.

SELECT Creation_time N'Statement Compilation Time', Last_execution_time N'Last Execution Time', Total_physical_reads N'total number of physical reads', Total_logical_reads/execution_count N'each logical read Count', Total_logical_reads N'total number of logical reads', Total_logical_writes N'total number of logical writes', Execution_count N'Number of executions', Total_worker_time/ +N'total CPU time used by Ms', Total_elapsed_time/ +N'Total time spent Ms', (Total_elapsed_time/execution_count)/ +N'Average Time Ms', SUBSTRING (St.text, (Qs.statement_start_offset/2) +1, (case statement_end_offset when-1Then 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 Qscross APPLY sys.dm_exec_sql_text (qs.sql_handle) StwhereSUBSTRING (St.text, (qs.statement_start_offset/2) +1, (case statement_end_offset when-1Then 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 Performance Analysis--execution of SQL times and number of logical times

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.