Vous êtes sur la page 1sur 1

Troubleshooting SQL Server 2005/2008 Query Performance/Scalability Issues

This flowchart is meant to address at a high level the most common issues that can affect performance and scalability in SQL Server 2005/
2008 implementations. This is an iterative process and should be performed only in a test environment.

Work left to
right, top to 1. READ 2. CAPTURE 3. EVALUATE 4. RESOLVE
bottom

Search: www.microsoft.com/ Tool:


TechNet for: SQL Management Studio

Troubleshooting Update Statistics


Auto Create and YES
Performance Problems
Update Statistics
in SQL Server 2005 Statistics Enabled?

Have Auto Create and Update Run the sp_updatestats procedure


Statistics been disabled, to update all the statistics in the
indicating that the statistics database
Use the SSMS Database Options might be out of date?
feature to determine if Auto
Create and Update Statistics
are enabled
Search: support.microsoft.com
for ID 224587

Troubleshooting NO Perform Index


Application and Query
Performance Analysis
Tool:
SQL Profiler
YES Remove any join or index hints
Evaluate in SSMS that may no longer be valid
Table/Index Scans?
Slow-Running Evaluate the validity of the search
arguments
Queries
Ensure there are no columns
Copy each of the slow-running inside expressions or functions in
queries into a query window and Are there tables or index scans
Search: support.microsoft.com that could consume large a predicate that would disallow an
for ID 243589 evaluate the execution plan
OPTIMAL EXECUTION PLANS

amounts of IO? index seek


Use the SQL Profiler
TSQL_Duration Template to Use the INCLUDE clause in an
Troubleshooting Slow- determine the long-running index to minimize key lookups
running Queries queries with the longest
duration and consuming the NO Evaluate the query in the Database
most IO Tuning Advisor

Query Too Complex?


Tool:
SQL Profiler
Search: SQL Server Books On
Line
Are there too many joins, temp YES Rewrite Query
tables, sub-queries and/or
Database Tuning control of low language to allow
Advisor High CPU Usage for optimal execution plans?

Try forcing a different plan with a


join or index hint
NO
Try breaking the query into
Use the SQL Server Standard smaller parts
template to determine queries
consuming the most CPU

Faster in SSMS?
YES Examine App for Modify
Result Handling Application Code
Does the query run faster in the
SSMS query window than in
from the application?
Ensure that the application is Ensure that only the results that
returning all of the results as soon are needed are being requested,
as possible to the client and that all results are consumed
as soon as possible
NO

Cannot Get an
More In-Depth
Optimal Plan? YES
Analysis
Statistics are up-to-date, all of
the above steps have been
followed, and it seems that the
Search on support.mcirosoft.com
optimizer has not selected an
and msdn.microsoft.com for more
optimal plan?
in-depth query tuning resources

Perform Index
Evaluate in SSMS Hash Joins, Sorts, YES and Query
and/or Filters? Analysis

Are there hash joins, sorts, and/ Determine indexes that will best
Copy each of the problematic
or filters displayed in the support this query, using the SSMS
queries into a SSMS query window
execution plan? query plan or the Database Tuning
and evaluate the query
Advisor.

Tool:
Search: support.microsoft.com
SQL Server Profiler
for ID 271509

How to Monitor SQL


Server Blocking
Blocking Examine
Blocking? YES Open Transactions? YES Transaction
Handling Logic

Is the blocking script showing Are there currently open Ensure that the transactions are all
BLOCKING

Use the sp_blocker_pss80 transactions (can be captured


that there are blocks occuring? committed and rolled back
procedure outlined in article using DBCC OpenTran()) correctly within the application
271509 to determine if there is
code, or within the stored
blocking
procedures
Search: support.microsoft.com
for ID 169960

Analyzing and
Avoiding Deadlocks in
SQL Server Tool:
SQL Server Profiler

Evaluate SQL Server


Examine
Deadlock Tracing Deadlocks?
YES Deadlock Trace
Transaction
Information Handling Logic
Search: support.microsoft.com
for ID 832524 The trace and/or error logs will Ensure that resources are being
Use the trace flags outline in Are there deadlocks occuring in identify which spids are involved
the system? acquired in the same order and
How to Resolve a article 832524 or use the in the deadlocks and the command held for the shortest possible time
Profiler Deadlock Events in a will be in the input buffer
Deadlock Ensure that user input is not being
Profiler trace to log deadlock requested in the middle of a
information transaction
ADVANCED TOOLS EXECUTION PLAN REUSE

Tool:
Search: www.microsoft.com/ SQL Server Profiler
technet for:
Batch Compilation, Ad hoc or Dynamic
Recompilation, and Queries? YES Rewrite Queries
Plan Caching Recompilations

Are the queries built


Try using prepared statements,
dynamically or on an ad hoc
stored procedures, or
basis?
sp_executesql to reduce
compilations
Use the Profiler trace outlined in
the article to identify
recompilation issues NO

Recompliations?
YES Rewrite Queries

Are there excessive Try using prepared statements,


recompilations? stored procedures, or
sp_executesql to reduce
compilations
Try changing the database
PARAMETERIZATION property
between forced and simple

Search: www.microsoft.com/
downloads for: Search: www.microsoft.com/
Search: www.codeplex.com downloads for:
for:
SQL Server 2005
RML Utilities for SQL
Performance DMVStats 1.01
Server
Dashboard

Search: SQL Server Books On


Line for:

SQL Server 2008


Management Data
Warehouse

Vous aimerez peut-être aussi