Sunteți pe pagina 1din 1

SQL Server Query Performance Tuning:

A 12–Step Program

CHECK FOR Make certain EXAMINE THE FILTERS


TABLES + ROWCOUNTS you know the
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 4 Make sure to work
searchable so a full with the smallest
scan isn’t needed) Know when the possible logical set
predicate is applied–
Look for select * or scalar should be earlier
functions (the more data brought rather than later
Sub-queries back, the less optimal it may be
to use certain functions
EXAMINE THE
REVIEW EXISTING KEYS, EXECUTION PLAN
Set statistics on (set
CONSTRAINTS statistics IO on + set
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, not the
plan

What is primary key estimated plan


Know what objects definition, and is it
exist (avoid duplicating clustered?
efforts 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
Look for logical reads
8 (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
have parameterized RE-RUN
CONSIDER ADJUSTING INDEXES index that includes every
statements) THE QUERY
column that satisfies the query

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

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

Abuse of wildcards (*) —


Join/query/table hints Nested views that go pulling 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 SolarWinds. All rights reserved.

S-ar putea să vă placă și