High Performance SQL Server DBA
High Performance SQL Server DBA
July 2010
TABLEE OF CONTEN
O NTS
Introducttion ........................................................................................................ - 2 -
Storage Managem
M ment ........................................................................................ - 8 -
Performa
ance Mana agement ............................................................................. - 10 -
Bottlen
neck/Resp ponse Tim me Analysiis ........................................................... - 10 -
Worklooad Analyssis ......................................................................................... - 11 -
Ratio Analysis
A ................................................................................................ - 11 -
Capacity Managem
ment ..................................................................................... - 12 -
Change Managem
M ment ....................................................................................... - 14 -
Conclusio
on ........................................................................................................ - 14 -
About Em
mbarcade
ero and SS
SWUG.org
g ........................................................... - 15 -
Embarcadero
o Technologie
es -1-
The High
H Performance SQL Server DBA
INTRO
ODUCTIION
SQL Server DBAs have always tackleed complex tasks amidsst shifting priorities, and pressures have
only mounte
ed in recent years. Several trends im
mpacting SQ
QL Server DBAs:
More Data Da ata growth iss exploding. DBAs increasingly manage terabyte es and even
abytes of datta. This grow
peta wth has creatted a relentless demand
d for increase
ed storage and
a has
madde common database
d anagement tasks such as back-ups, capacity pla
ma anning, and SLA
compliance morre complex.
Consolidation / Virtualizatiion The rush to consolidate and virtualize dataa centers has given
rise to
t new kindss of issues in
n database administratio
a on, from virtu
ualized serve
er capacity
planning, to performance monitoring
m an
nd troubleshhooting, to in
ncorporatingg SQL Azure e, and
more e.
Not Enough Pe eople Expeerienced DBAs have alw ways been ha ard to find. Even
E with inccreasing
freeddom to hire,, many organ nizations can e talent or exxpertise theyy need to manage
nnot find the
theirr critical data
abases. This translates in
nto a higher ratio of data
abases mana aged per DB BA,
whicch in turn putts the onus on
o organizattions to find ways that will
w empowerr SQL Serverr DBAs
to bee more prod ductive and scalable.
U
Understandi ng the Database Design
n
Embarcadero
o Technologie
es -2-
The High
H Performance SQL Server DBA
C
Catching Poor-Performin
ng SQL Earlyy
M
Managing Sttorage
M
Managing Pe
erformance
M
Managing Capacity
M
Managing Change
UNDEERSTAN
NDING THE DATABA
ASE DESIGN
E
At some point, all DBAss will be requ
uired to support two or more types of database e platforms.
Whether the
e new datab base comes viav a new ap pplication, a company accquisition, orr the brainstorm of
an app deve
eloper, suppporting a new w database can be challenging.
R
Reducing da
ata redundan
ncy
O
Organizing business
b req
quirements
P
Providing a foundation
f o the database design
of
R
Reducing de
evelopment and mainten
nance time
Embarcadero
o Technologie
es -3-
The High
H Performance SQL Server DBA
e example, we
In the above w have provvided flexibility by norm malizing a bitt to support 1 to N addre
esses
and phone numbers
n forr each custom mer rather than limiting it to two and three. Hoowever, we have
h
kept some denormaliza
d tion in the Zip
Z Code tab ble with the City
C and State Codes co olumns and in
i the
Customer taable with thee Organization Name an nd Industry, allowing us tot minimize the numberr of
joins when accessing
a the data.
Embarcadero
o Technologie
es -4-
The High
H Performance SQL Server DBA
OPTIM G POOR
MIZING R-PERF
FORMING SQ
QL
CATCHING THE PROBLEEM EARLYY
Performancee problems can occur att any stage ofo the develo
opment lifeccycle, but catching them m early is
always muchh less expen each a production environment. Tra
nsive than lettting them re aditionally,
developers have been responsible
r f preventin
for ng poor-perrforming SQL code. For developers,, the
database is a black box, and they do not necessarily have access
a to the
e informationn they need to
d resolve problems.
pinpoint and
IDENTIFYYING TH
HE MAIN SOURCE E BOTTL
E OF THE LENECK
When lookin ng at databa
ase bottlene
ecks, it's imp early identifyy the source,, which usually falls
portant to cle
into one of four
f categorries:
Insufficient hardware
h
D
Database co
onfiguration issue
A
Application code
c proble
em
P
Poor-perform
ming SQL
Understanding the sourrce of the bo ottleneck helps you alloccate resources efficientlyy. For examp
ple,
there are many cases where a mana ager purchasses additional hardware to address a performan nce
n the end, tu
issue that, in b a databasse configurattion or SQL tuning issue
urns out to be e. The costly
hardware up pgrade fails to improve the
t bottlene eck.
Embarcadero
o Technologie
es -5-
The High Performance SQL Server DBA
On the othe er hand, if the worst perfforming SQLL statement is consuming 86% of thee CPU (see second
s
profiling graaphic on pagge 7), you might spend a day or long
ger trying to
o tune the SQ
QL statemennt.
Clearly, this would be a much more efficient approach than n upgrading the hardwarre.
SQL TUNING
U TECHNIQU
E UES
Often timess, the main bottleneck
b is a SQL state
ement taking
g up too manny resourcess. Once the
offending SQL has been n identified, developers can analyze A yourself these questions to
e the code. Ask
entify poor-p
help you ide performing SQL:
S
A the table
Are e and index statistics up to date?
A there any missing indexes?
Are
D any of the columns need
Do n extended histogram
m or frequen
ncy statisticss?
A all the un
Are nique and not-null consttraints corre
ectly defined on the colu
umns and tab
bles?
Is the databa
ase choosing
g the right access path?
By drawing the picture, you can find d the best pa ath through the query. Start
S at the most
m selectivve filter
ratio, and fo
ollow the join t smallestt result set size, then on to the smallest two
n to the nextt table with the
table join sizze.
Then down to
T o CUSTOMER RS as
t
that join only returns 8 row
ws.
T
Then we join up to
ORDER_LINE ES only givingg us
115 rows, etcc.
Embarcadero
o Technologie
es -6-
The High
H Performance SQL Server DBA
However, in the
t profiling session
s beloww, we can see that there is one SQL statement that acccounts for 86
6% of
the load. The
e load can be reduced sign
nificantly by tu
uning this one
e query.
Embarcadero
o Technologie
es -7-
The High
H Performance SQL Server DBA
STORA
AGE MANAG
GEMEN
NT
Storage management iss complex enough, but when w you manage differrent databasse platformss and
versions on a variety of operating syystems, the challenge
c be
ecomes extrreme. For SQ QL Server, yo
ou need
to account for
f acceptab ble file place
ement (isolatting log files)) and ensure
e your opera
ating system
volumes aree properly mirrored
m and configured. Todays DB BA may be dealing
d with Sybase systems,
databases, transaction
t logs, and segments in th he morning anda then have to switch gears to de eal with
Oracle table
espaces, temmpfiles, and redo logs inn the afterno oon. Just remmembering the
t storage syntax
s
commands to manage the t many divverse platforrms can be a difficult tassk.
A storage problem
p may also have a major impact on dattabase perfo ormance. Frragmentationboth
globally andd at the ob
bject levelcan result in
n significantt unnecessa
ary I/O for a database. Wasted
space in tabbles and ind
dexes can also
a cause problems
p and contributee to excessive table an
nd index
scan times.
New feature es from seve eral database e vendors caan protect aggainst these problems. With
W the
introductionn of dynamicc manageme ent views in SQL
S Server 2005,
2 and in
ncreased opttions with SQQL
Server 2008, SQL Serverr DBAs have e additional views
v to trou
ubleshoot fragmentation n. By coupliing this
data with a solid
s mainte enance plan,, you can preeemptively detect
d and re
esolve issues that could have
otherwise reesulted in an n interruption of service. SQL Servers Managem ment Studio (SSMS) provides
a starting pooint for workking with youur SQL Serve e substantial options including
er databasess. There are
wizards and other tools for working with SQL Se erver. The options
o presented are, of
o course, version-
specific to support
s incre
easing functionality in th
he database engine, and d there are no provisionss for
working with h other data abase platforrms with SSMMS.
age problem
In addition, object stora ms can createe major perfformance roa adblocks in a database. A DBA
must undersstand how to o detect and
d eliminate these
t issues as quickly ass possible.
Embarcadero
o Technologie
es -8-
The High
H Performance SQL Server DBA
Wasted Space While it may not n seem likee a problem,, a table or index with more
m allocate
ed
space thhan it needs can hamperr performancce. For exam mple, if the pages
p QL Server object
of a SQ
containeed in a data warehouse are
a not 100%% utilized, th
he object will examine more
m pages than
t
necessary during tabble scans. This
T increases response time
t for userr queries. Th
he same problem
arises with Oracle ta
ables that ha
ave high-watter marks ab
bove the area as where datta resides.
So, how doe es a SQL Server DBA de etect and diaagnose these e object storage problems in less fa
amiliar
databases? After all, eacch engine ha as its own se
et of diagnosstics. Moreoover, how can you ensure e that
no downtim me is attributed to space outages acrross many se ervers? As a high perform
mance DBA, you
should estab blish an arou und-the-clocck, multi-platform, fully-aautomated database
d moonitoring solution
that allows you
y to config gure storage e thresholds and proactiive notifications across all
a your criticcal
databases before
b you develop
d stora
age-related problems. Such
S a plan should
s take into account the
multiple typpes of databa ases in their environmen nt and also focus
f on bein
ng completeely automate ed 24/7,
at least for critical
c datab
bases.
What aboutt diagnosingg and remedying database and object storage problems
p tha
at hurt
performance? This can be
b a challenge for the SQL
S Server DBA
D tasked with
w taking on
o additiona al
platforms. The
T fact is there are vast differences in diagnostiic and treatm
ment methods that existt across
abase platforms.
diverse data
Embarcadero
o Technologie
es -9-
The High
H Performance SQL Server DBA
Because sto
orage manag gement can be complexx, especially if you work on o multiple database
d platforms,
you must bee proactive in your appro oach and auutomate as much
m of the managemen nt as possible. A
two-phase approach
a to setting thre
eshold alerts starts with standard
s thresholds designed to uncover
space issuess threatening mance, then customizes them to me
g overall sysstem perform eet the uniqu
ue
needs of your environm ment. For SQL Server, tarrget your datta and log fiile groups th
hat are experiencing
high growthh rates so you have plentty of notice to solve pottential proble
ems.
The starting
g point is to define
d the different
d metthods of analysis that willl be used accross all plattforms
and then appply a set of diagnostics and actionss that can bee used for eaach platform under each
method. These method ds of analysiss include:
Bottleneck/Resp
ponse Time Analysis
A
Workload Analyssis
Ratio
o Analysis
The followin
ng examiness how each method
m can be used to manage
m the performancce of any dattabase.
BOTTLENECK/R
RESPONSE TIME ANALYSIIS
Regardless of the platfoorm, when a database is running, every connecte ed process is
i either worrking or
waiting to perform
p workk. A process that is waiting may meaan nothing, or
o it can be an
a indicator that a
database bo ottleneck exxists. DBAs use bottlenecck or respon
nse time analysis to dete
ermine wheth her
perceived bottlenecks
b are
a hurting performance
p e.
Bottleneck analysis
a is an
n essential method
m of measuring pe erformance because
b it he
elps you tracck
where a dattabase has been
b spendinng its time. In SQL Serve er, looking at
a Buffer Cacche Hit Ratioos,
number of times
t specific queries are run and ho ow long theyy run, along with disk quueues and otther
activity coun
nters will hellp point you in the direcction of a poo
orly perform
ming query or hardware issue.
i
Embarcadero
o Technologie
es - 10 -
The High
H Performance SQL Server DBA
WORKLO
OAD ANALYSIS
N
Workload analysis involvves the investigation of two critical areas
a of data
abase performance:
e consumption and activvity
Sesssion resource
SQLL execution analysis
a
RATIO ANALYSISS
Ratio-basedd analysis wa as for many years
y the only techniquee DBAs had tot diagnose the cause of o a
database sloowdown. Yo ou are probably all too fa
amiliar with the
t Oracle buffer
b cache hit ratio, Microsoft
procedure plan
p hit ratio
o, Sybase datta cache hit ratio, and so
o forth. Man
ny performan nce experts advise
a
that such rattios are now w worthless and
a misleading because of advancess in bottlene eck/response e time
analysis. The
ere is an element of trutth to these claims,
c but so
ome ratios are
a still quite
e valuable, su
uch as
the Oracle library cache e hit ratio and the Microssoft and Syb
base procedu ure plan hit ratios.
When working through performancce issues, bufffer cache hiit ratios in SQQL Server will
w help defin ne
utilization on the server. In addition
n, by looking
g into the qu
ueries and query executiion plans, yo
ou can
see whetherr and how offten indexess are used an nd whether the
t indexes have been created
c on the most
Embarcadero
o Technologie
es - 11 -
The High
H Performance SQL Server DBA
beneficial co
olumns in th
he queried taables. By loooking at DMMVs for suggested indexe
es (and unussed
indexes), yo
ou can gain insights into likely index candidates. Then you can
c review frragmentation ratios
to determine which inde exes may ne eed to be rebbuilt or reorganized.
Ratios can be
b helpful, but the inform mation is being muddied d in many installations, by
b factors su
uch as
feature sets, server funcctionalities and other issues outside the databasse engines realm
r of conntrol and
reporting. For
F example e, the use of a SAN disk subsystem can c confuse disk access reporting to o mask
issues of data access, making
m it difficult to dete
ermine wheth
her a slow disk system may
m be the ro oot
cause of performance isssues.
Similar measures exist for SQL Server and will beb helpful ba ased on the specific situations youre
e trying
to address. There are a host of cou unters availab
ble from Perrformance Monitor
M at the operating system
e counters will let you exxplore and re
level. These ecord informmation for everything from the disk
subsystem to
t the instance performa ance. Furthe er, with the DMVs
D available for query performan nce and
index analyssis, you can gain additio
onal insights into suggesstions for invvestigations.
CAPAC
CITY MANAG
GEMEN
NT
Many DBAs find it difficcult or almost impossible
e to implemeent capacity manageme ent, as their day-to-
d
es simply leave no room for historica
day activitie al and proacttive analysis. This is unfo
ortunate beccause
proper capa acity plannin
ng can help both
b the DBBA and mana agement, answering imp portant quesstions
such as, Ho ow much mo ore storage will
w this dataabase need ini six months? and Is this
t databasse server
currently underutilized?
anning gene
Capacity pla erally involve
es three proccesses:
Colle
ection of keyy database metrics
m
Histo
orical analysis of collecte
ed metrics
Fore
ecasts of futu
ure needs
Every organ
nization will have
h differen
nt needs, bu
ut in general, most shoulld collect the
e following
information:
Snappshots of glo obal storagee usage, inclu
uding Sybasse device me etrics, SQL Server
S database
statisstics, Oracle
e tablespacee data, and database
d objject statisticss that conce
ern space usa
age.
Elem
ments such as a total alloca
ated space, used space,, and free sp pace should all be colleccted as
well as other perrformance-re elated itemss like numbe
er of chained d rows
Snappshots of pe
erformance metrics,
m inclu
uding key da
atabase statiistics like I/O
O performance and
wait events
Snap
pshots of ressource consu
umption, inccluding metrrics such as CPU
C usage, memory usa
age,
and user traffic
While some e DBAs have been able tot get by using scripts an
nd manual processes
p to manage sto orage
and performmance, the burden
b in using such techniques for capacity planning is usuually too high
h. These
tasks are complicated greatly
g by muulti-platform
m database environments
e s, as well as the need to build
Embarcadero
o Technologie
es - 12 -
The High Performance SQL Server DBA
and maintain a reposito ory that holds all the neccessary statisstics. In addittion, DBAs are
a faced witth
challenges in
i the time itt takes to maanually weavve together collection sccripts and sccheduled job bs as
well as analyyze and man nage the gen neration of complex
c histtorical and foorecasting reports. Withh all
these comp plications, it is
i obvious th
hat manual maintenance
m e is not practtical for the high
h perform
mance
SQL Server DBAespecially when moving into other DBMS platforms.
ng technique
The followin es to simplifyy capacity management
m t will save yo
ou time and headaches:
Build
ding a repossitory to tracck key databa
ase metrics
Crea
ating statisticcal collections for everytthing you wa
ant to track across
a your key
k databases
Sche
eduling to au
utomatically run collectio
ons as often
n as needed
Embarcadero
o Technologie
es - 13 -
The High
H Performance SQL Server DBA
CHAN
NGE MANAG
A EMENT
T
Todays SQL Server DBA A sits at the center of a complex sysstem that tou uches many participantss: data
modelers, database
d devvelopers, arcchitects, bussiness analyssts, software developers, and more. At any
given time, each databa ase is physiccally instantia
ated across a number off different en nvironments, each
of which ma ay contain anny one of sevveral version ns of the sam
me database e. Furthermo ore, the desig
gn of a
particular da
atabase is tyypically storeed in several locations ussing a multip
plicity of too
ols, which maay
include a daata modeling g tool, a SQL development tool, a database
d adm ministration tool, a database
change man nagement to ool, etc.
Without a ro
obust changge managem ment solutionn for your muultiple databbase platformms, you could be
putting the work of the other discip
plines of adm
ministration at
a risk; a sing
gle change could
c result in a
abase issue or,
serious data o even worrse, could be e a direct refflection on your
y ability to
o successfully
administer the
t database e.
CONC
CLUSIO
ON
The combinnation of multiple databa ase types an
nd versions, added
a datab
base comple exity, more data,
d
and lower headcount haas become a real challen nge for the SQL
S Server DBA
D who wo orks hard to
gh database availability and perform
maintain hig mance. The key
k to keepin ng database es running well
w is to
implement a strategy fo
or ensuring good
g design
n documenta ation and hig
gh quality SQ
QL. Proper storage,
s
Embarcadero
o Technologie
es - 14 -
The High
H Performance SQL Server DBA
ABOUT EMB
BARCADERO AND
A S
SSWU G.ORG
G
Embarcaderro Technologies provide es a complette set of pro
ofessional-grrade databasse tools for the
t high
performance SQL DBA A to take coontrol of SQQL, storage, performancce, capacityy manageme ent, and
change man nagement. ER/Studio
E allows you to reverse eng gineer the ERD
E so you understand
u the task
at hand. Em mbarcadero DB Optimizer XE, DBA Artisan XE, and Analystt Series Too ols are desiggned to
deliver prod ductivity gains, regardless of your current levvel of experrtise. DB Ch hange Mana ager XE
enables you u to simplifyy, automate, and report database change. In ad ddition, thesse essential support
tools will givve you the confidence
c to
o carry out even
e the moost complex tasks, whichh goes a long g way to
ensuring the e success of your databa ases.
Another valuable resou urce for higgh performa ance SQL DBAsD is the SQL Serve er Worldwid de Users
Group, SSWWUG.ORG, which w provides articles, video programs, web bcasts, virtua
al conferencces, and
many otherr resources to t help you manage th hese comple ex environm ments. You can registerr for the
SSWUG.OR RG newslette er to stay onn top of lateest advancem ments, disco over valuable insight, an nd learn
from expertts. The site allows you to search th he site for sp
pecific article
es, editorials, scripts, an
nd more
that addresss very speciffic challenge
es that affectt your organizations dattabase environment.
Ste phen Wynkoop is a Miccrosoft SQL Server MVP and the fou under of
WUG.ORG. He
SSW H has worked with SQLL Server since its inceptio on in
1989 and writess a daily colu
umn and newwsletter on the site, as well
w as a
weeekly SQL Serrver video prrogram. Stepphen is the author
a of moore than
12 books
b transla
ated into 7 languages around the world.
w Stepheen has
spo
oken at nume erous technoology conferrences and reports
r reguularly on
the happeningss in the technology world.
Embarcadero
o Technologie
es - 15 -
Embarcadero Technologies, Inc. is the leading provider of software tools that empower
application developers and data management professionals to design, build, and run
applications and databases more efficiently in heterogeneous IT environments. More than 90 of
the Fortune 100 plus an active community of more than three million users worldwide rely on
Embarcaderos award-winning products to optimize costs, streamline compliance, and
accelerate development and innovation. Founded in 1993, Embarcadero is headquartered in
San Francisco with offices located around the world. Embarcadero is online at
www.embarcadero.com.