2 DB-Time-based Oracle Performance Tuning: Theory and Practice RMOUGFeb 2008Graham Wood, Uri Shaft, John BeresniewiczOracle Corporation
3 The 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.
4 Agenda Brief History of Oracle Performance Tuning Methods DB Time: What is it?DB Time: Data SourcesDB Time Method
5 Oracle Tuning Methods Prehistory Dark Ages Renaissance Debug code Counters/RatiosBSTAT/ESTATSQL*TraceRenaissanceIncreased instrumentation inc. Wait EventsMove from counters to timersSTATSPACK
7 Why 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!
8 The 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
9 The DB Time Method Supports multiple scopes for diagnosis DatabaseInstanceSessionClient idModule/ActionSQL IDMore inclusive, less intrusive
10 Database 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.
11 A Single Session Single session with Database Black Box server TIME BrowseBooksRead ReviewsFor One BookAdd to CartCheckoutTIME= time spent in database
12 Fundamental 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
14 Active 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.
15 Multiple 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
16 Wall Clock (Elapsed) Time The Basic RelationshipDatabase TimeAvg. Active Sessions =Wall Clock (Elapsed) TimeBrowseBooksRead ReviewsFor One BookAdd to CartCheckout= time spent in databaseTIME
24 Where 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
25 Where to find DB time? V$SQL V$ACTIVE_SESSION_HISTORY ELAPSED_TIME Also wait class timesV$ACTIVE_SESSION_HISTORYSample per secondCount = time
26 Active 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
27 Estimating 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
33 Average 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
34 What 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
35 EM 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
38 DB 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
39 Performance 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?
40 The DB Time Method Scope Set Goal Investigate DB time distribution Identify the largest potential for improvementModify systemEvaluate against Goal
41 The DB Time Method Scope What is the problem? Business Requirements Resource capacityResource contentionSystem wide or individual Business Function
42 The DB Time Method Set Goal Quantitative Establishes the STOP TUNING criteriaShould be business driven for applications (X per day)
43 The 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
44 The 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
45 The 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
46 The DB Time Method Need to have examples here Instance level and SQL level maybe?
47 The 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
52 Summary 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
53 New In 11g – Enhancements for RAC ADDM has “Database” analysis modeNew AWR “Database” reportEM Performance screens for RAC enhanced to support new server capabilities.