You are on page 1of 17

The High Performance SQL Server DBA

Managing Multiple Database Platforms for Performance & Availability



By Scott Walz, Sr. Director of Product Management at Embarcadero Technologies and
Stephen Wynkoop, Microsoft SQL Server MVP and Founder of SSWUG.org

July 2010

Americas Headquarters EMEA Headquarters Asia-Pacific Headquarters


100 California Street, 12th Floor York House L7. 313 La Trobe Street
San Francisco, California 94111 18 York Road Melbourne VIC 3000
Maidenhead, Berkshire Australia
SL6 1SF, United Kingdom
The High
H Performance SQL Server DBA

TABLEE OF CONTEN
O NTS

Introducttion ........................................................................................................ - 2 -

Understaanding thee Databasse Design n ............................................................... - 3 -


Visualizzing the Database
D .
................
................................................................ - 3 -
Data Normalizattion vs. Peerformancce ............................................................ - 4 -

Optimizinng Poor-PPerforming SQL ..................................................................... - 5 -


Catchinng the Prooblem Earrly ........................................................................... - 5 -
Identifyying the Main
M Sourrce of the Bottlene eck ............................................. - 5 -
SQL Tuuning Tech hniques .................................................................................. - 6 -

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 -

About the Authorss ........................................................................................... - 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:

Multtiple SQL Seerver Versioons Microssoft SQL Server continue


es to evolve and advance with
each
h release, and SQL Serve er DBAs are required to be experts on *all* verssions of SQLL Server.
New uch as CLR functions, are
w features, su e stretching DBAs from their comfort zone into a
dom
main traditionnally reserved for develo
opers.

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.

More Database es While so


ome DBAs use SQL Servver only, or manage
m onlyy a handful of
o
abases, mostt manage do
data ozens and evven hundred ds. As databases grow inn both size and
a
num
mber, so have
e database platform
p type
es and versio
ons. Today, many SQL Server
S DBAss
manage comple ex heterogenneous datab base environments, makiing it more challenging
c to
extend ones SQ
QL Server skiills into othe
er database types.
t

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.

Addded Comple exity While


e all of the abbove trends are adding tremendouss complexityy to a
DBAAs daily workk, Microsoft and other database
d venndors have been
b responding with
dataabases whichh are increassingly self-m
managed or self-tuning through the use of more
m
dynaamic access to system he ealth information and au utomated annalysis tools.. While
advaancements such as Micro osofts datab base tuning and suggestion tools arre time-savinng
imprrovements, DBMS
D enviro
onments are e growing more complexx and require knowledgeable
humman interventtion and man nagement. DBAs
D have to quickly ab
bsorb and ma aster new
inforrmation with
h each new database
d rele
ease. This ca
an be especcially acute when
w working
g with
multtiple databasse versions, and adding multiple database platfforms can exxponentially
incre
ease the commplexity of the analysis needed.
n

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.

Regardless of these chaallenges, as an


a overworkked SQL Servver DBA, you are expectted to keep key
database syystems availa
able and opttimized for high
h perform
mance. Performance problems come e from
many source es, and you need a strattegy that will contribute the most to high availab
bility. This sttrategy
should inclu
ude the follo
owing compo onents:

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

This paper will


w outline techniques
t to streamline
e and autom mate the man nagement of these criticcal areas
to deliver hiigh database
e performan
nce and availlabilityreg
gardless of th
he database type or verssion.

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.

A great wayy to become more intima ate with a ne


ew database e and its stru
ucture is to understand the data
model. Mosst data mode eling tools allow DBAs to reverse en ngineer the database.
d Doing so allow
ws you
to visualize the
t table strructure, relattionships, an
nd stored procedures, ass well as dep pendencies. By
seeing the database on paper, yo ou can unde erstand the immpact of a potential
p cha
ange, generaate
reports for other
o users, and analyze the consiste encies (or inconsistenciees) among co ommon data a
elements.

VISUALIZZING THE DATAB


BASE
A logical da
ata model is an invaluablle tool for managing
m commmon objeccts across da atabases, especially
across multiiple databasse platforms. The logicall model removes all plattform-specifiic propertiess and
allows you to
t use busine ess names foor tables andd columns. This
T provide es traceabilitty for busine
ess
terms and ruules enforce
ed in the model while ma aintaining traceability ba
ack to the ph hysical
implementa ations. Logiccal modelingg helps DBA As by:

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

Whether you inherit an existing database or build a new on


ne, optimizinng performannce often sta
arts
with a thoro
ough understtanding of th
he database
e design. By staying in th
he loop with data archite
ects and
modelers du uring the de
evelopment phase,
p you will
w have opp portunities to examine the physical data
model and its
i potential impact on performance
p e.

Embarcadero
o Technologie
es -3-
The High
H Performance SQL Server DBA

DATA NORMALIIZATION VS. PERRFORMAN


NCE
Logical data
a architects like to normalize the stru ucture so tha
at data redundancy is re
educed and the
t
design is as flexible as possible.
p A flexible
f design is good, but not at thhe expense of performaance.
Providing yoour expertisee with the phhysical desig gn on what tables
t can bee denormalized (i.e. merrged,
rolled up/doown, or horizzontally/verttically split) can
c ensure that the design is both flexible and
optimized foor performance.

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.

Performance e issues with


h an existing
g database may
m make de enormalizing
g the structure too drastic of a
change. In that
t case, most
m data moodeling toolss allow you to t reverse en
ngineer an existing
e dataabase
with currentt row counts and partitiooning properrties. Then youy can easilly create a re eport that re
eveals
which tabless may be go ood candidattes for new partitioning,
p and you can rethink exiisting partitioning
strategies. You
Y can also o get a clearrer picture off table relationships and
d start strategizing how tot index
specific tablles.

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

Also, the roles of the daatabase deveeloper and database


d administrator are
a expandin ng. As a high
performance DBA mana aging multip
ple platformss, you shouldd enable developers to solve, or at least
recognize and commun nicate, how their code is affecting da
atabase perfformance. One
O strategy is to
create oppo ortunities to offload SQLL performancce tuning too developmeent. Enabling
g developerss to
identify and
d fix poor performing cod de before it hits production can save everyone time
t and energy,
while improving database performa ance.

However, th he first step is


i to identifyy that the performance problem
p is re
elated to poor-performin
ng SQL
or a differen
nt type of boottleneck.

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.

So, how cann we identifyy the source of a perform


mance bottleeneck? The key
k is to proffile the activvity of
the databasse to calculatte the load on
o the databbase, pinpoint poor-perfforming SQLL, and top se essions.
For example e, all the major databasee platforms have
h perform
mance viewss, such as V$
$SESSION on n
Oracle or MASTER.SYSP
M PROCESS on SQL Serve er and Sybasse. These pe
erformance views
v describbe the
current state
e of the connections on the databasse and which h SQL statem
ments the coonnections area
executing.

By sampling g these table es, you can create


c a clea
ar picture of load on the database an nd identify poor-
p
performing SQL, as well as where time is being spent in the e database. If time is being spent wa aiting
for CPU resoources and thet highest CPU C consumming SQL sta atement is only 3% of the total activiity (as
shown in thee first profiling session graphic
g on page
p n its not worrth the time to tune all your SQL
7), then
to free up th
he CPU. In th his case, a hardware upg
grade is the best way to allocate ressources.

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.

If the bottleneck turns out


o to be acccess to a sha ared resourcce, the developer needs to ask the DBAD
what the issue is so the DBA can takke the appro opriate actio
on. However, if the issue is row level locking
plication is doing
or if the app d a lot off single row operations (when
( it should be using
g arrays), the
e
solution to the
t problem m is in the hands of the developer.
d

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?

For the finall step, of kno


owing wheth her the database chose the right patth, or even if the SQL
statement iss reasonable e, the best and most efficient step iss to lay the query
q out visually. This is often
referred to as
a Visual SQ QL Tuning or VST. Try dra awing out thhe tables (eitther on your own or usin ng a
he detail tables hovering
tool) with th g above the master
m tablees, indicating
g table sizes, filter ratioss, and
two table jooin sizes.

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.

To the right iss an example


T e of a
V
Visual SQL Tuuning diagramm. A
good candidate for the be est
execution path is clear.

First we start where the am mount


of rows returnned after filte
ering is
t lowest, in
the n this case OR RDERS
at 0.34%.

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

ng session below, a DBA may


In the profilin m spend too
o much time to
t make small gains by tryiing to tune in
ndividual
statements.

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.

The two major storage managemen


m nt concerns area always availability an nd performance. Storage e
problems ca an quickly brring down a database. Just let an Oracle archive e log destina
ation reach
maximum ca apacity or le
et a Microsofft SQL Serve er transaction n log fail to expand and see how a dynamic
d
transaction processing system
s reactts. Fortunate ely, database e vendors ha ave providedd a number of new
capabilities that address availabilityy issues. All popular
p data abases now sport
s uto-extend feature
an au
allowing theeir underlying operating system filess to automattically grow to t meet the demand of
increasing data
d volumess. IBM DB2 containers,
c O
Oracle dataffiles, or Microsoft SQL Server databa ase and
transaction log files all have
h the cappability to exxpand when necessary. Still, S such fea
atures are no ot a
100% guarantee againstt failure. A SQL
S Server database
d file could meett an imposed d growth limmit or an
Oracle temp porary table space temp pfile could be denied exxpansion at the t operating system levvel if a
disk drive ru
uns out of sppace. Therefo ore, a DBA must
m still mo onitor storag ge to ensure availability.

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.

Oracle 10g introduced automatic


a sttorage mana agement (ASSM), which allows
a a DBAA to provide the
database en ngine with a set of disk drives
d for the
e database to
t automaticcally manage e for file placcement.
If hotspots are
a discovered, automattic relocation n is accompllished without DBA intervention. In terms
of global fra
agmentationn assistance, Oracle8i an nd above offer locally maanaged table
espaces,
eliminating the need for full tablesppace reorgan nizations.

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

Regardless of platform, object stora


age problem
ms generally include fourr componen
nts:

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.

Poor Exxtent Proxim


mity A dataabase engine es read-ahe
ead mechaniisms work more
m efficienttly when
objects are containe
ed in extentss that are clo
ose to one another. For example, SQ QL Servers Read
R
Ahead Manager
M can
n read much larger groups of data when
w its target object ha
as extents annd
pages th
hat are contiiguous. Sybaase is the same. Converssely, when an object hass poor exten nt or
page proximity, scan times can increase.
Out of Sync
S Data Order
O Wheen indexes have
h a logica
al order that does not match the actual
physical order of data stored in the databasse, index acccess performmance can be e affected. Iff the
logical and
a physical orders are in sync, the disk
d head ca an scan in on
ne direction instead of moving
m
back andd forth to ob
btain the neeeded inform
mation. Otherwise, the diisk head will skip across the disk
many timmes. In SQL L Server, for example, in
ndex fragmentation is on ne of the mo
ore common culprits
when de etermining root cause foor performannce issues.
Forwardded Rows Each row in a table should fit on a single
s page, if possible, except for la
arge
object/text tables. However,
H if a row expandds because of o the growtth of variable
e length datta, the
database may either relocate th he row to anoother page and
a leave be ehind a poin
nter to the neew
page, orr split the row between two
t or more
e pages. Neither situatio ed as they increase
on is preferre
the amoount of I/O necessary
n to obtain the row.
r This is seen
s in Oraccle as chained or migrateed rows
and in SQL Server and Sybase as a forwardedd rows.

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

The solutionn is to design an advancced storage diagnostic


d a management system
and m that incorp
porates
the following characteristics:

Eliminates all the


e guessworkk and labor from
f handlin
ng database storage pro
oblems in
erogeneous environments.
hete

Allow andle complex storage dilemmas


ws you to ha d e unfamiliar with the und
evven if you are derlying
dataabase platforrm.

Alertts you when storage issu


ues in the da
atabase objeects are draining performmance by vissually
identifying stora
age problemms and pinpo ointing the objects that require
r atten
ntion.

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.

A best practtice is to reb


build your da
atabase objeects for maxiimum perforrmance at re egular intervals. For
example, create a find-a and-fix job that searchess the entire database
d (orr a particularr set of objects) for
objects thatt violate your specified set
s of thresho olds. Then reorganize thhem for bettter performa ance.

Once these jobs are sett up and scheduled, you


u will never have
h to manu
ually reorgan
nize your databases
again.

PERFO NCE MANAG


ORMAN GEMENT
DBAs want their
t databaases to run as quickly as possible. Thhe same can be said for every person who
uses a system that conn nects to thosse databasessthey want their queries and processes to havve the
shortest posssible response times. Again,
A the sittuation is complicated when
w you havve more than one
database platform. As with
w storage management, the variables and rem medies differ from one platform
p
to the next. As a result, you need to
o put together a platform m-neutral roadmap that applies to each
e of
the databasse engines yo ou manage.

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

If Oracle latch contentio


on or heavy DB2 table-sccan activity has
h been dra agging a databases
performance, you can use
u bottlenecck analysis to o pinpoint thhe root causse. Once one
e or more off the
potential soources has be
een identifie
ed, drill dow
wn to detail about
a the sesssions and objects
o that are
a
causing the problem.

Embarcadero
o Technologie
es - 10 -
The High
H Performance SQL Server DBA

This methoddology is thee strategy off choice for top


t performance analystts in the indu ustry. This being
the case, ne
early every database ven ndor has tailo
or edits engines to repo
ort metrics to
o analyze
bottlenecks and respon nse times. Orracle 10g inttroduced new metrics in its V$ perfo ormance view ws that
enable DBA As to understtand bottlen necks and response time es at global and session levels. Microosoft
SQL Server made wait events
e availa
able via an undocumente ed DBCC co ommand (DB BCC
SQLPERF(W WAITSTATS) and now exposes that data d via dynaamic management view ws (DMVs), and
Sybase offers new moniitoring viewss in engine versions
v 12.5
5.03 and aboove.

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

When perfo ormance on a database drops


d suddeenly, one or two
t sessionss often gene erate the bullk of the
workload. The
T issue is system balan nce. In a welll-balanced system, no single session n should connsume
the bulk of resources
r for an extende ed period off time, with the
t exceptio on of batch job processe es that
are run safely in non-peak hours. If individual
i se
essions are using
u a majority of system
m resources, the
DBA should d examine ea ach problemm session in detail
d to unccover session
n activity.

Normally, thhis can be ea


asily accomp plished by viewing sessio on metadata a coupled with resource
consumptio on and statisttical execution statistics. Most datab base engines provide va ast details re
egarding
a sessions current
c and historical acttivities. SQLL Server, for instance,
i pro
ovides this data
d via seveeral
dynamic ma anagement views,
v one being
b dm_exxec_session.

Understanding current and


a historica al SQL execuution patterns will enablle a databasse analyst to have
the second set of data points
p neede ed to properly perform workload
w an
nalysis. Optimmizing SQL code
will produce
e the secondd-best performance-enhancing boosst available for f a databasewith pro oper
physical dessign being th
he first. But what
w set of metrics
m shou
uld you use to
t evaluate good
versuus bad
SQL? Naturally, factors such as overrall elapsed time, CPU time, and I/O O activity pla
ay a part. Butt other,
more subtlee factors can make a differencelike e the numbeer of times a statement is executed, or
whether sorrts are done in memory or o on disk. As
A we saw on n page 6, thiis is where SQL analysis
becomes more of an artt form than a science.

All the database vendorrs offer a win


ndow into SQ
QL analysis. Oracle 10g has the mosst complete set of
ered by any vendor.
metrics offe v Micrrosoft SQL Server
S offers code profiling utilities that
t can be used
u to
collect and measure SQQL and stored procedure e executionss. Sybase hass made a go ood start withh its
SQL execution views in versions 12.5.03 and above. DB2 offfers its own SQL tracing g capabilitiess.

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.

More obscu ure ratios can


n also be useeful. For exaample, if you
u were told that a Sybase
e table had 100
1
forwarded rows, would you conside er this good or bad? Of course,
c you cannot answwer this quesstion
unless you know
k how many
m total rowws are in the
e table. But if
i you knew that
t 98% of all rows in yo
our
Sybase table e were forwaarded, this iss enough infformation too make a reoorganization decision. In these
types of situ
uations, the application
a o proper ratio analysis can
of c be advantageous.

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

Implementing to eds by depiccting upcoming storage,,


ools to accurrately predicct future nee
perfo
ormance, an
nd resource requirementts through visual graphss (example below)
b or well-
form
matted HTMLL reports tha
at managers easily understand

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.

Very few org


ganizations look
l at database change e manageme ent as a sing gle, unified process.
p Manny
assume thatt database change
c mana agement is a natural outtcome, at the juncture of o database
managemen nt, software configuratioon managem ment, and daata modeling g. The first sttep in developing a
robust database change e manageme nize it as a sttandalone process or disscipline,
ent solution is to recogn
arities that make
with peculia m it quite different fro
om software change man nagement.

As the DBA, you should d develop a database


d change manag gement proccess that pro ovides a vieww into
the changess occurring across
a all of your multiple database platforms. You
Y should establish
e sollid
baselines annd manage change
c to th
hose baselines. In addition, best pra actices dicta
ate that you
periodically revisit the baseline
b to ensure
e that elements
e are
e properly ve
ersioned and d if needed, reset
the baseline
e. Having a consistent view with con nsistent repo
orts, no mattter the datab
base
platform, prrovides confidence that database ch hange is beinng managed d. You can also
a incorporate
database coonfiguration into your ch hange manag gement process. A change to a con nfiguration setting
s
could have asa much imp pact as an ob bject change e.

Third party applications


a s present the
eir own unique set of cha allenges. Thhough most limit the DB BAs
control, at the end of th
he day, you are
a still respoonsible for an
a applicatio
ons performance. A
comprehenssive databasse change management
m t process allo
ows you to understand
u a predict
and
changes tha at occur wheen vendor uppdates are deployed.
d W that info
With ormation, the e DBA has a starting
point to diagnose problems that ma ay arise wheen applying patches.
p Witthout a proccess in place, you
have to rely solely on th
he quality of the vendors updates an nd their ability to remoteely troublesh
hoot.

ortant as objject level changes are ch


Just as impo hanges mad de to the seccurity model. With increasing
compliance and reporting pressures, DBAs musst establish thatt they havve control over the data
abase.
Being able to
t flag erronneous, or eve en maliciouss changes to
o database se ecurity, and then act on those
changes, can be critical to meeting expected co ompliance leevels.

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

performance, capacity managemen


m nt, and chang
ge managemment are also
o critical. Such a strategy
should be platform-inde
p ependent an
nd as automatic as possible.

In the end, the


t responsiibility for the
e performancce of an orgganizations database
d strructure falls on
o the
DBA. And a well-preparred DBA sho ould have all the tools sh
he needs to ensure high database
availability and
a performance.

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.

ABOUT THE AUTHORS


Scoott Walz hass more than 15 years of experience
e in database
devvelopment and
a serves ass senior dire ector of prodduct manage ement
for Embarcadero Technolo ogies. In this position, Sccott overseess the
dire e company's database product family, while focu
ection of the using
on database de evelopment and adminisstration prod ducts. Prior to
t
ning Embarccadero four years
join y ago, Scott served as developm ment
d for Louisviille Gas & Electric. He ho
lead olds a bache elor's degree e in
commputer information syste ems from Western Kentu ucky Universsity.

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.

You might also like