2DB-Time-based Oracle Performance Tuning: Theory and Practice RMOUGFeb 2008Graham Wood, Uri Shaft, John BeresniewiczOracle Corporation
3The following is intended to outline our general product direction 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.
4Agenda Brief History of Oracle Performance Tuning Methods DB Time: What is it?DB Time: Data SourcesDB Time Method
5Oracle Tuning Methods Prehistory Dark Ages Renaissance Debug code Counters/RatiosBSTAT/ESTATSQL*TraceRenaissanceIncreased instrumentation inc. Wait EventsMove from counters to timersSTATSPACK
7Why Do We Care About Time? Performance Is Always About Time Human time is critical to the enterpriseSystem time includes human and IT resource time to accomplish business goalsSystem performance affects business goals“Time is money.”Performance improvement usually means doing things fasterMethod: find where system time is spent – reduce it!
8The DB Time Method Uses combination of cumulative and sampled DB Time ‘Always on’ data onlyCombines best of current methodsLow intrusionDetailed dataNo scope necessary for collectionsNo requirement to reproduce problemWorks for concurrency problems such as locking
9The DB Time Method Supports multiple scopes for diagnosis DatabaseInstanceSessionClient idModule/ActionSQL IDMore inclusive, less intrusive
10Database time (DB Time) Time spent in database calls by foreground sessionsIncludes CPU time, IO time and wait timeExcludes idle wait timeThe lingua franca for Oracle performance analysisDatabase time is total time spent by user processes either actively working or actively waiting in a database call.
11A Single Session Single session with Database Black Box server TIME BrowseBooksRead ReviewsFor One BookAdd to CartCheckoutTIME= time spent in database
12Fundamental conceptsActive Session = Session currently spending time in a database callDatabase Time (DB Time) = Total time session spent in all database callsAverage Activity of the Session (% Activity) = The ratio of time active to total wall clock timeBrowseBooksRead ReviewsFor One BookAdd to CartCheckoutTIME= time spent in database
14Active sessions Foreground sessions in a database call Backgrounds are also interestingEither on CPU, waiting for IO, or waiting (not idle)V$ACTIVE_SESSION_HISTORY is a collection of timed regular samples of active session attributesActive sessions are foreground sessions contributing to DB time in any given moment.
15Multiple Sessions DB Time = Sum of DB Time Over All Sessions Avg. Active Sessions = Sum of Avg. Activity Over All SessionstAt time t we have 2 active sessionsUser 1User 2User 3User nTIME= time spent in database
16Wall Clock (Elapsed) Time The Basic RelationshipDatabase TimeAvg. Active Sessions =Wall Clock (Elapsed) TimeBrowseBooksRead ReviewsFor One BookAdd to CartCheckout= time spent in databaseTIME
24Where to find DB time? V$SYS_TIME_MODEL V$WAITCLASSMETRIC_HISTORY STAT_NAME = ‘DB time’Accumulated value over entire instanceV$WAITCLASSMETRIC_HISTORYAVERAGE_WAITER_COUNTIt is precisely Average Active SessionsV$SYSMETRIC_HISTORY“Database Time Per Second”, “CPU Usage Per Sec”Units are Centi-seconds per secondValue is 100 x Average Active Sessions
25Where to find DB time? V$SQL V$ACTIVE_SESSION_HISTORY ELAPSED_TIME Also wait class timesV$ACTIVE_SESSION_HISTORYSample per secondCount = time
26Active Session History (ASH) Persisted samples of active session informationSessions contributing to DB time at time of samplingOne-second sampling interval is a great defaultAllows simplified AAS computationsDB time and Average active sessions can be computed by aggregating ASH samples
27Estimating DB time with ASH ASH sample count is value of active sessions function at sample timesActive sessionstimet0t1DB TimeDB time is area under curvet = 1 sec
33Average active sessions Average active sessions is the rate of change of DB time over time.Time-normalized DB timeFull-time equivalent sessionsNot whole sessionsHow many full-time virtual sessions to do the work?ComparableAcross systemsAcross time periods
34What are the units? Time / time = unitless? DB time accumulates in micro- or centi-secondsTime-normalized metrics are per second of elapsedCenti-seconds (foreground time) per second (elapsed)Centi-users per secondUser seconds per elapsed second (normalize time units)Active session seconds per secondActive sessions
35EM Performance page Cumulative DB time by wait class v$waitclassmetric_history and v$sysmetric_history1 minute intervals
36% activity = DB time *100 / elapsed time Used for individual sessions Percent Activity% activity = DB time *100 / elapsed timeUsed for individual sessions
38DB Time Tuning DB Time can be aggregated at multiple levels: Database / instanceService / module / actionSession / user / client idSQL id / rowsourcePerformance improvement for Oracle database means doing the same work in less DB Time
39Performance Problem Resolution 101 Discover the problem:User phone call or other complaintMetric threshold alert or system monitoringScope the problem:How widespread is it?How severe is it?In other words: Who or what is wasting DB Time and how much is being wasted?Diagnose the problemScope the solutionHow much of the pain can be relieved?
40The DB Time Method Scope Set Goal Investigate DB time distribution Identify the largest potential for improvementModify systemEvaluate against Goal
41The DB Time Method Scope What is the problem? Business Requirements Resource capacityResource contentionSystem wide or individual Business Function
42The DB Time Method Set Goal Quantitative Establishes the STOP TUNING criteriaShould be business driven for applications (X per day)
43The DB Time Method Investigate DB time distribution Identify major contributors to DB time at the selected scopeSystem scopeV$SYS_TIME_MODELV$ACTIVE_SESSION_HISTORYV$SQLIdentify high load service, sessions and SQLIdentify resource constraints or contention
44The DB Time Method Investigate DB time distribution Session scope V$SESS_TIME_MODELV$ACTIVE_SESSION_HISTORYIdentify if database is the problemIdentify high load SQLIdentify application efficiency issuesIdentify resource constraints or contention
45The DB Time Method Identify the largest potential for improvement What can be changed that will produce the greatest reduction in ‘scoped’ DB time?ParametersSystemApplicationSQLDesignModify system
46The DB Time Method Need to have examples here Instance level and SQL level maybe?
47The DB Time Method Evaluate against Goal Did our changes to the system achieve our goal?If not return to step 3 and repeatIf we have reached our goal STOP
52Summary DB Time is the fundamental performance metric The DB Time Method uses many different sources of DB time within the database to allow many different scopes of performance tuningTime based diagnosis removes ‘value judgments’ from performance analysis
53New In 11g – Enhancements for RAC ADDM has “Database” analysis modeNew AWR “Database” reportEM Performance screens for RAC enhanced to support new server capabilities.