SQL Performance Tuning common statements (excerpt online)

Source: Internet
Author: User

1. Import the trace file into the table

SELECT IDENTITY (BIGINT11 as RowNumber,* into TableNamefrom fn_trace_gettable ('trace.trc'default)

2. Querying for statements with large CPU overhead

SELECT Top  -Total_worker_time/Execution_count asAvg_cpu_cost, Plan_handle, Execution_count, (SELECT SUBSTRING(text, Statement_start_offset/2 + 1,       ( Case  whenStatement_end_offset= -1           Then LEN(CONVERT(nvarchar(Max),text))* 2          ELSEStatement_end_offsetEND -Statement_start_offset)/2)     fromsys.dm_exec_sql_text (sql_handle)) asQuery_text,creation_time fromsys.dm_exec_query_statswhereCreation_time> '2014-11-01' and(Total_worker_time/Execution_count)> 146341ORDER  by [Avg_cpu_cost] DESC

3. Query blocking

SELECTA.*  fromSys.[sysprocesses]aWHEREA.[spid]> -  and db_name(A.[dbid])='DBName'  andA.spid<> @ @SPID  andA.blocked> 0

4. Query the number of connections

SELECT COUNT (*from[sys]. [dm_exec_sessions] WHERE [session_id] >  -

SQL Performance Tuning common statements (excerpt online)

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.