Back To Basics: DB Time Performance Tuning: Theory and Practice
Back To Basics: DB Time Performance Tuning: Theory and Practice
Back to Basics:
DB Time Performance Tuning: Theory and Practice
John Beresniewicz, Graham Wood
Oracle America ST Partners June, 2011
The following is intended to outline our
general product direction. It is intended for
information purposes only, and may not be
incorporated into any contract. It is not a
commitment to deliver any material, code, or
functionality, and should not be relied upon in
making purchasing decisions.
The development, release, and timing of any
features or functionality described for
Oracle‟s products remains at the sole
discretion of Oracle.
Agenda
• Time
• Database Time
• Average Active Sessions
• Techniques
• The DB Time Method
• Tools
• ADDM
• EM User Interface
• Active Reports
Oracle Tuning Methods: A History
• Prehistoric (v5)
• Debug code
• Dark Ages (v6)
• Counters/Ratios
• BSTAT/ESTAT
• SQL*Trace
• Renaissance (v7/v8)
• Introduction of Wait Event instrumentation
• Move from counters to timers
• STATSPACK
• Modernity (v10)
• DB Time Tuning – Tuning using fundamental notion of time spent in database
• Multiple scoping levels
• Always on, non-intrusive
• Built into infrastructure: instrumentation, ASH, AWR, ADDM, EM
Why Do We Care About Time?
• “Time is money”
User 2
User 3
User n
TIME
t
= time spent in database
Visualizing DB Time
User 1
User 2
User 3
User n
t0 t1
4
3
2
1
• Time-normalized DB time
• Time units in numerator and denominator must
synchronize to produce the proper metric
Average Active Sessions
• Comparable
• Across systems
• Across time periods
<Insert Picture Here>
DB Time and
System Performance
System Load and DB Time
• More users
• => More calls
• => DB time increases
• Larger transactions
• => Longer calls
• => DB time increases
• IO performance degrades
• => IO time increases
• => DB time increases
• Host is CPU-bound
• => foregrounds accumulate active run-queue time
• => wait event times are artificially inflated
• => DB time increases
Run-queue Run-queue
Db file sequential read On CPU Db file sequential read On CPU
• V$SYSMETRIC_HISTORY
• “Database Time Per Second”, “CPU Usage Per Sec”
• 10g units = centi-secs/sec (100xAvg. Active Sessions)
• 11g new metric “Average Active Sessions”
• V$SQL
• ELAPSED_TIME and CPU_TIME
• Wait class times:
APPLICATION, CONCURRENCY, CLUSTER, USER_IO
• V$ACTIVE_SESSION_HISTORY
<Insert Picture Here>
• In-memory: V$ACTIVE_SESSION_HISTORY
• Sampling interval = 1 second
• On-disk: DBA_HIST_ACTIVE_SESS_HISTORY
• Sampling interval = 10 second
COUNT(*) = DB Time
GROUP BY ?
ASH Math: COUNT(*)=DB Time
• V$ACTIVE_SESSION_HISTORY
• COUNT(*) = DB time in seconds
• DBA_HIST_ACTIVE_SESS_HISTORY
• COUNT(*) * 10 = DB time in seconds
Estimating DB Time with ASH
t1
DBtime ActiveSess ions
t0
Avg Active Sessions and DB Time
ASH sample count is value
Active sessions of active sessions function
at sample times
DB time is area
under curve t = 1 sec
DB Time
t0 time t1
DB Time: ASH vs Time Model
ASH Timing for Nano-Operations
Techniques:
The DB Time Method
Where is DB Time used?
• ADDM
• ASH report
Determine where
or database
time isjust
spent, and reduce
ask ADDM it!
The DB Time Method: Process
• System scope:
• Resource limits – is problem outside the DB?
• Application scope:
• Service, module, action
• Resource contention (e.g. latches)
• SQLID, rowsource
• Session scope:
• Long running SQL
• Resource contention (e.g. enqueues)
DB time
Identify Potential Solutions
• SQL issues
• SQL Tuning Advisor => Indexes, SQL profile
• Re-write SQL
• Design issues
• Access Advisor => Indexes, physical layout
• System issues
• Initialization parameters
• Add resources
Modify System
Tools:
ADDM
Enterprise Manager
Active Reports
Tools for Applying DB Time Method
• Variably scoped:
• Host to instance to SQL and even database block
• Scoped to database for RAC (new in 11g)