Sei sulla pagina 1di 1

SQL Server Query Performance Tuning:

A 12–Step Program

CHECK FOR Make certain EXAMINE THE FILTERS


TABLES + ROWCOUNTS you know the

STA RT
rowcount
KNOW THE
2 SELECTIVITY OF
THE TABLES
1
Make sure you’re Examine WHERE and
working with tables JOIN clauses — what is
(not views) the filtered rowcount?
3
Most useful
ANALYZE for RIGHT, LEFT,
QUERY COLUMS OUTER joins
Look for
CASE, CAST,
CONVERT
SARG-able (make
an index searchable 4 Make sure to work
so a full scan isn’t with the smallest
Know when the possible logical set
needed)
predicate is applied–
Look for select * or scalar functions should be earlier
(the more data brought back, the rather than later
Sub-queries less optimal it may be
to use certain functions
EXAMINE THE Set statistics on (set
REVIEW EXISTING KEYS, EXECUTION PLAN statistics IO on + set
CONSTRAINTS Check to see if covering statistics time on)
AND INDEXES indexes can be created (avoid
duplication, overlapping)
6
Run the
5 Check the actual plan
plan, not the
What is primary key estimated plan
Know what objects exist definition, and is it
(avoid duplicating efforts clustered?
later on) RECORD
RESULTS
ADJUST Focus on logical
RE-RUN Focus on THE QUERY I/O (number of
logical reads)
THE QUERY most expensive
operations first
7
8 Look for logical reads
(fewer logical I/Os
means faster query)
Record the
results and
9
compare

Consider a filtered
index (but not if you
Consider covering index—an index have parameterized RE-RUN
CONSIDER ADJUSTING INDEXES that includes every column that statements) THE QUERY
satisfies the query

Make small
11
changes 10
Look to reduce ENGINEER OUT
logical i/o THE STUPID

Code-first generators (EMF,


LNQ, nHibernate) can be
Cursors and mis-used and
bloat the plan cache
12
row-by-row Scalar functions
processing

Abuse of wildcards (*)— pulling


Join/query/table hints Nested views that go back too many rows
across linked servers

Find and fix query performance faster with SolarWinds Database Performance Analyzer. Free 14-day trial at: www.solarwinds.com/dpa-download
© 2015 Confio Software, a SolarWinds company. All rights reserved. 866-266-3461

Potrebbero piacerti anche