rmoug new features 10g (2)asdasdads

135
Performance Tuning in Oracle 10g Feel the Power ! Kyle Hailey [email protected] http://oraperf.sourceforge.ne t

Upload: bsrksg123

Post on 25-Oct-2015

32 views

Category:

Documents


5 download

DESCRIPTION

ASDSADSD

TRANSCRIPT

  • Performance Tuning in Oracle 10gFeel the Power !Kyle [email protected]://oraperf.sourceforge.net

  • New FeaturesMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMisc

  • Metrics a new 10g feature to make our lives easierMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • MotivationWhat inspired Metrics?Why should you care ?

  • Eating your Spinach How do we find Performance ProblemsWith StatisticsStatistics have always been a PainHow do YOU find bottlenecks with statistics?YOU DO THE MATH This is TEDIOUS(and your boss probably doesnt even appreciate you for it )

  • First Tedious Step SQL> Select value from v$sysstat where name=physical reads;

    VALUE --------------- 1,533,787

    Not much help Why? Let see

  • This tells you Nothing 1,533,787

    IOstime30 minutes30 minutestimeGOODBAD

  • How do You find the Delta?Wheres the Beef ?

  • YOU Need to do MATH to find OutTake value at time A Take value at time BDelta = (B-A) orRate = (B-A)/elapsed time

  • Current MethodsOracle 6 Utlbstat.sql/Utlestat.sqlCreates tables, inserts, deletesOracle 8 introduced StatspackImprovement, but needs to be set up and administered (by guess who)Another Option Write your own ScriptsTake time to write, no standardsIn Summary These options take time whose time?

  • YOUR TIME

  • Solution ! 10g Metrics

    Available Immediately at your fingertips for your enjoyment and relaxation,Introducing MetricsAutomatedImmediateAlways thereTime saving (whose time? YOUR time)

  • Metrics dependability at your fingertips

    Pre-Set intervals15 second60 second10 minutes30 minutesCurrent Value for DeltasRatesper second per transactionRatios Percentages

  • Serious Geek Stuff :Our Metric FamilyWait EventsV$EVENTMETRIC (60 secs )V$WAITCLASSMETRIC (60 secs)StatisticsV$SESSMETRIC (15 secs Deltas)V$SYSMETRIC (15 and 60 secs deltas) FilesV$FILEMETRIC ( 10 minutes)SQL (the secret is out)x$kewrtsqlstat (30 Minutes) not a metric cumulates values up to 30 minutes, then snapshots it to dba_hist_sqlstat

  • The Solution Table v$sysmetricSQL> desc v$sysmetric BEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNIT

  • Now Whats the IO?No Calculations, just a simple select :

    SQL> Select VALUE , METRIC_UNITfrom v$sysmetricwhere name=Physical Reads/

    (Gives per second and per transaction)

  • Answer at your fingertips 3 IO/sec

    IOstime30 minutes30 minutestimeGOODBAD 513 IO/sec

    1,533,787

    X

  • We solved whats Happening now but What if your problem happened 10 minutes ago?How do we get History?What happened in the past?

    More work, Time and calculations by YOU

  • That was now. What was then?High rateLots of IOLow rateLittle IOv$sysstat physical reads

  • Solution! Metric History Tables

    Last 60 minutes of history, in memory

  • Family of Metric History Tables At your fingertips :StatisticsV$SYSMETRIC_HISTORY (60 seconds) (including 3 minutes of 15 second history as a bonus!)File IOV$FILEMETRIC_HISTORY (10 minutes)WaitsV$WAITCLASSMETRIC_HISTORY ( 60 seconds)

  • 1 hour of 60 second deltasdeltadeltadeltadeltadeltadeltadelta

  • Thats not all Folks, as a bonus:3 Minutes 15 second deltasv$sysstat physical reads3 minutes of 15 second deltas

  • Both Stored in Same Table v$sysmetric_history Not saved to disk but summary is60 minutes of 1 minute deltas3 minutes of 15 second deltas

  • What was IO 30 minutes ago?SQL> Select VALUE , METRIC_UNITfrom v$sysmetric_history where METRIC_NAME = Physical Reads and END_TIME < ( sysdate - (30/(24*60))) and END_TIME > ( sysdate - (35/(24*60))) /Once again the answer is at your fingertips

  • How about a 2 days ago?Long Term History, 7 daysStatisticsDBA_HIST_SYSMETRIC_SUMMARYDBA_HIST_SYSMETRIC_HISTORY (alerts)DBA_HIST_SYSSTAT (cumulative)WaitsWAITCLASSMETRIC_HISTORY (alerts) DBA_HIST_SYSTEM_EVENT (cumulative)File IODBA_HIST_FILEMETRIC_HISTORY (alerts)DBA_HIST_FILESTATXS (cumulative)SQLDBA_HIST_SQLSTAT

  • EM Exposing Metrics

  • That was the Introduction to MetricsWe sawCurrent deltas : Metrics TablesHour History : Metric History TablesWeek of History : DBA_HIST TablesNow lets Look at the GroupingsStatisticsWaitsFile I/O

  • StatisticsRaw : v$sysstatCurrent Rates: v$sysmetric 15 & 60 seconds15 Second 60 SecondSession Stats1 Hour : v$sysmetric_history (in memory)7 Days : dba_hist_sysmetric_summary (with AWR)

  • v$sysmetric 15 Secs for 3 minutesBuffer Cache Hit RatioMemory Sorts RatioExecute Without Parse RatioSoft Parse RatioDatabase CPU Time RatioLibrary Cache Hit RatioShared Pool Free %Txns Per LogonPhysical ReadsPhysical WritesPhysical Reads DirectRedo GeneratedLogonsUser CallsLogical ReadsRedo WritesTotal Table ScansFull Index ScansDB Block GetsConsistent Read GetsDB Block ChangesConsistent Read ChangesExecutionsUser Transaction Per SecPer Sec and Per TransactionPer Sec

  • v$sysmetric 60 Sec for an hour Buffer Cache Hit Ratio Memory Sorts Ratio Redo Allocation Hit Ratio User Commits Percentage User Rollbacks Percentage Cursor Cache Hit Ratio Rows Per Sort Execute Without Parse Ratio Soft Parse Ratio User Calls Ratio Global Cache Average CR Get Time Global Cache Average Current Get Time Global Cache Blocks Corrupted Global Cache Blocks Lost Current Logons Count Current Open Cursors Count User Limit % SQL Service Response Time Database Wait Time Ratio Database CPU Time Ratio Row Cache Hit Ratio Row Cache Miss Ratio Library Cache Hit Ratio Library Cache Miss Ratio Shared Pool Free % PGA Cache Hit % Process Limit % Session Limit % Txns Per Logon

  • v$sysmetric 60 Sec rates sec/txn for an hour Physical Reads Physical Writes Physical Reads Direct Physical Writes Direct Physical Reads Direct Lobs Physical Writes Direct Lobs Redo Generated Logons Open Cursors User Calls Recursive Calls Logical Reads Redo Writes Long Table Scans Total Table Scans Full Index Scans Total Index Scans Total Parse Count Hard Parse Count Parse Failure Count User Commits User Rollbacks User Transaction DBWR Checkpoints Background Checkpoints Network Traffic VolumeResponse Time Disk Sort Enqueue Timeouts Enqueue Waits Enqueue Deadlocks Enqueue Requests DB Block Gets Consistent Read Gets DB Block Changes Consistent Read Changes CPU Usage CR Blocks Created CR Undo Records Applied User Rollback Undo Records Applied Leaf Node Splits Branch Node Splits PX downgraded 1 to 25% PX downgraded 25 to 50% PX downgraded 50 to 75% PX downgraded 75 to 99%.Per Second and TransactionPer SecPer Transaction

  • v$sessmetric: Session MetricV$sessmetricBEGIN_TIME END_TIME INTSIZE_CSEC SESSION_ID SESSION_SERIAL_NUM CPU PHYSICAL_READS PGA_MEMORY HARD_PARSES SOFT_PARSES PHYSICAL_READ_PCT LOGICAL_READ_PCT

    No HistoryOnly a one 15 second Delta

  • Stats Family of Tables Statistics Metrics

    v$sessmetricBEGIN_TIME END_TIME INTSIZE_CSEC SESSION_ID SESSION_SERIAL_NUM CPU PHYSICAL_READS PGA_MEMORY HARD_PARSES SOFT_PARSES PHYSICAL_READ_PCT LOGICAL_READ_PCTv$metricname GROUP_ID GROUP_NAME METRIC_ID METRIC_NAME METRIC_UNITv$sysmetric_summary BEGIN_TIME END_TIME INTSIZE_CSEC -> intsize GROUP_ID METRIC_ID METRIC_NAME NUM_INTERVAL MAXVAL MINVAL AVERAGE STANDARD_DEVIATION METRIC_UNITv$sysmetric_historyBEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNITv$sysmetric BEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNITv$sysstat STATISTIC# NAME CLASS VALUE HASHv$metricgroup GROUP_ID NAME INTERVAL_SIZE MAX_INTERVALv$sessstat STATISTIC# NAME CLASS VALUE HASH

  • WaitsRaw : v$system_eventCurrent Deltas : v$eventmetric (60 seconds)1 Hour : n/a7 Days : dba_hist_system_event (cumulative)

  • Desc v$eventmetricSQL> desc v$eventmetric Name Type ---------------------------------- ------ BEGIN_TIME DATE END_TIME DATE INTSIZE_CSEC NUMBER EVENT# NUMBER EVENT_ID NUMBER NUM_SESS_WAITING NUMBER TIME_WAITED NUMBER WAIT_COUNT NUMBER

  • Select from v$eventmetric

    SQL> select en.name name, num_sess_waiting WAITERS, time_waited, wait_count from v$eventmetric em, v$event_name en where wait_count > 0 and en.event# = em.event# /

  • v$eventmetric resultsNAME WAITERS TIME_WAITED WAIT_COUNT------------------------------ ---------- ----------- ----------pmon timer 1 5875 20process startup 0 13 1rdbms ipc message 7 41104 168control file sequential read 0 0 10control file parallel write 0 2 20log file parallel write 0 0 1SQL*Net message to client 0 0 47SQL*Net more data to client 0 1 4SQL*Net message from client 4 14721 47SQL*Net more data from client 0 0 1queue messages 2 12012 24Queue Monitor Wait 1 3000 1Queue Monitor Task Wait 0 0 1

  • FilesRaw : v$fileioCurrent Delta : v$filemetric ( 10 Minutes)1 Hour : v$filemetric_history ( 1 hour, 7 points)7 Days : dba_hist_filemetric_history (alerts only)

  • V$FILEMETRIC_HISTORY

    SQL> select BEGIN_TIME,FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY;

    BEGIN_TI FILE_ID PHYSICAL_READS-------- ---------- --------------04:12:16 1 20804:12:16 2 600

    04:02:18 1 60004:02:18 2 189

    03:52:15 1 192203:52:15 2 2082

    ... For the last hour

  • Metrics in summaryCurrent rates automatically calculatedHistory of Rates for an hour in memoryHistory kept for a week on disk

  • MetricsV$METRICGROUPV$METRICNAME

    Current ValuesV$SYSMETRICV$SESSMETRICV$FILEMETRICV$EVENTMETRICV$WAITCLASSMETRICV$SVCMETRIC

    Last HourV$SYSMETRIC_HISTORYV$FILEMETRIC_HISTORYV$WAITCLASSMETRIC_HISTORYV$SVCMETRIC_HISTORY

    V$SYSMETRIC_SUMMARY avg, std dev, max, min

    V$METRICV$METRIC_HISTORY

    Combined view onto the other metric tablesWeek of Historydba_hist_sysmetric_summarydba_hist_system_event (cumulative)dba_hist_filemetric_history (alerts)

  • Metrics Family of Tables

    Stats ( V$stat_name)Waits ( V$event_name )FilesRawV$sysstatv$system_eventv$event_histogram v$system_wait_class v$fileio Now

    v$metricgroupv$metricnameV$sysmetric v$eventmetric v$waitclassmetric v$filemetric1 HourV$sysmetric_history V$sysmetric_summary v$waitclassmetric_history v$filemetric_history7 days

    DBA_HIST_*SYSMETRIC_SUMMARY SYSSTAT (cumulative)SYSMETRIC_HISTORY (alerts)SYSTEM_EVENT(cumulative)WAITCLASSMETRIC_HISTORY (alert) FILESTATXS (cumulative)TEMPSTATXS (cumulative)FILEMETRIC_HISTORY (alert)

  • Wait ClassesMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • Wait Classes Administrative (39)switch logfilerebuild index Application (11)enqueues sqlnet break/resetCluster (113)Commit (1)Log file SyncConcurrency (12)Latches: cbc, lbc,Lib cache locksBuffer busy wait

    Configuration (20)log file sizeEnqueues: ST, HW, ITLLatch: redo copy,shared poolIdle (56)Network (25)System I/O (19)Scheduler (6)User I/O (12)Other (485)

  • Wait Classes in EM

  • Wait Class Tablesv$system_wait_classcumulativev$waitclassmetric Current ratesv$waitclassmetric_history Hour of rates (60 second intervals)

  • v$waitclassmetricBEGIN_TIMEEND_TIMEINTSIZE_CSECWAIT_CLASS_IDWAIT_CLASS#NUM_SESS_WAITINGTIME_WAITEDWAIT_COUNT Waits Metricsv$waitclassmetric_history BEGIN_TIME END_TIME INTSIZE_CSEC WAIT_CLASS_IDWAIT_CLASS# NUM_SESS_WAITING TIME_WAITED WAIT_COUNTv$event_name EVENT# EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3WAIT_CLASS_IDWAIT_CLASS# WAIT_CLASSv$system_wait_classWAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITEDv$system_eventEVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT TIME_WAITED_MICRO EVENT_IDNo in memory historydba_hist_system_event(Cumulative)dba_hist_waitclassmetric_history

    Only gets populated with alertsWait ClassesWait EventsCumulativeCurrent deltasLast HourLast 7 days

  • Time ModelMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • Time ModelNew conceptDB Time

    Total time for all database callscpu time wait time

  • Time Model areasTotal TimeCPUElapsed TimeSQL executionPlsql execution (sql execute subtracted out)Java executionConnection time

  • Time Model Components1) background elapsed time 2) background cpu time 1) DB time 2) DB CPU 2) connection management call elapsed time 2) sequence load elapsed time 2) sql execute elapsed time 2) parse time elapsed 3) hard parse elapsed time 4) hard parse (sharing criteria) elapsed time 5) hard parse (bind mismatch) elapsed time 3) failed parse elapsed time 4) failed parse (out of shared memory) elapsed time 2) PL/SQL execution elapsed time 2) inbound PL/SQL rpc elapsed time 2) PL/SQL compilation elapsed time 2) Java execution elapsed time

  • Total TimeTotal Database Time

  • Total and CPUDB CPU Time=~ DB Wait Time

  • Total and CPU and Parse TimeDB CPU Time DB Wait Time

    Parse ElapsedTime

  • Parse Time

    Parse ElapsedTime

  • Hard Parse Parse time elapsedhard parse elapsed time

  • Hard Parse Sharing CriteriaParse time elapsedhard parse elapsed time hard parse (sharing criteria) elapsed time

  • Hard Parse Bind MismatchParse time elapsedhard parse elapsed time hard parse (sharing criteria) elapsed timehard parse (bind mismatch) elapsed time

  • Time Model TablesCurrent cumulative valuesV$SYS_TIME_MODELV$SESS_TIME_MODEL

    AWR Snapshots of cumulative valuesDBA_HIST_SYS_TIME_MODEL

  • ASHMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • ASH A Revolution in MonitoringActive Session History New 10gEvery Second it collects data 1 hour of history in Memory for immediate access at your fingertips

    This hour of data could change your life

  • Its a Revolution and its an Evolution

    Oracle 6 ie the dark ages there was Cache Buffer Hit RatioOracle 7 turned the lights on Wait Events hallelujah I can see the light Oracle 10g ASH has landed

  • ASH Intelligence for the new Millennium

    Selectively Collects DataMore active, more data collected Less active, less data collectedIt self adjusts for your needs Old methods collect everything CostlyLimits fine Granularity

  • ASH In MemoryCollects active session data onlyHistory v$session_wait + v$session + extrasCircular Buffer - 1M to 128M (~2% of SGA)Flushed every hour to disk or when buffer 2/3 full

  • ASH Sizing Bigger isnt always BetterAvg row around 150bytes3600 secs in an hour~ Meg per Active Session per hourThats generally over an hour of ASH

  • v$active_session_history SESSION_ID NUMBER SESSION_SERIAL# NUMBER USER_ID NUMBER SERVICE_HASH NUMBER SESSION_TYPE VARCHAR2(10) PROGRAM VARCHAR2(64) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64) EVENT VARCHAR2(64) EVENT_ID NUMBER EVENT# NUMBER SEQ# NUMBER P1 NUMBER P2 NUMBER P3 NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER0 SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SQL_OPCODE NUMBER QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3)When

    Session

    SQL

    Wait SESSION_STATE VARCHAR2(7) WAIT_TIME NUMBERState TIME_WAITED NUMBER

    Duration

  • ConsumersTop SessionTop UserTop SQLTop ObjectTop Module.ActionTop Program Top ServiceTop ClientTop Wait XCPUWaitsEventI/OFileBlockTime

  • Top CPU Session Top CPU Session in last 5 minutes

    Select session_id, count(*)from v$active_session_history where session_state= ON CPU and SAMPLE_TIME > sysdate (5/(24*60)) group by session_idorder by count(*) desc;

  • Results Top CPU Session

    SESSION_ID COUNT(*) ---------- ---------- 265 236 264 115 257 52 271 22 276 1

  • ASH in OEM 10g

  • Family of ASH Tablesv$session_waitv$active_session_historywrh$active_session_historyV$session_wait_history

  • ASH Tablesv$session_wait SID SEQ# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAWWAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS WAIT_TIME SECONDS_IN_WAIT STATEv$event_nameEVENT_ID EVENT# EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_IDWAIT_CLASS# WAIT_CLASScurrent10 sampleshourwrh$active_session_historySNAP_DDBID INSTANCE_NUMBERSAMPLE_IDSAMPLE_TIMESESSION_IDSESSION_SERIAL#USER_IDSQL_IDSQL_CHILD_NUMBERSQL_PLAN_HASH_VALUESQL_OPCODESERVICE_HASHSESSION_TYPESESSION_STATEQC_SESSION_IDQC_INSTANCE_IDSEQ#EVENT_IDP1P2P3WAIT_TIMETIME_WAITEDCURRENT_OBJ#CURRENT_FILE#CURRENT_BLOCK#PROGRAMMODULEACTIONCLIENT_ID7 days (disk)1 in 10

  • AWRMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • Automatic Workload Repository Statspack on SteroidsMore efficient than StatspackKeeps stats every hourStores by default the last 7 days

  • Snapshoting

    BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END;/

  • DBA_HISTDBA_HIST_DATABASE_INSTANCEDBA_HIST_SNAPSHOT- DBA_HIST_SNAP_ERROR- DBA_HIST_BASELINE- DBA_HIST_WR_CONTROL ? (work load repository ?)- DBA_HIST_DATAFILEDBA_HIST_FILESTATXS only file number, no name- DBA_HIST_TEMPFILEDBA_HIST_TEMPSTATXS onl;y file number+DBA_HIST_SQLSTAT group by parent cursor plus DELTAs was (stats$sql_summary)DBA_HIST_SQLTEXT+DBA_HIST_SQL_SUMMARY identify litterals (was stat$sql_statistics)DBA_HIST_SQL_PLAN-DBA_HIST_SQLBIND-DBA_HIST_OPTIMIZER_ENV-DBA_HIST_EVENT_NAMEDBA_HIST_SYSTEM_EVENTDBA_HIST_BG_EVENT_SUMMARY sum of backgroundsDBA_HIST_WAITSTATDBA_HIST_ENQUEUE_STAT-DBA_HIST_LATCH_NAMEDBA_HIST_LATCHDBA_HIST_LATCH_CHILDRENDBA_HIST_LATCH_PARENTDBA_HIST_LATCH_MISSES_SUMMARY summed over parent latchDBA_HIST_LIBRARYCACHEDBA_HIST_DB_CACHE_ADVICEDBA_HIST_BUFFER_POOL_STATDBA_HIST_ROWCACHE_SUMMARY summed over rowcache entriesDBA_HIST_SGADBA_HIST_SGASTATDBA_HIST_PGASTAT

    DBA_HIST_RESOURCE_LIMITDBA_HIST_SHARED_POOL_ADVICE?DBA_HIST_SQL_WORKAREA_HSTGRMDBA_HIST_PGA_TARGET_ADVICEDBA_HIST_INSTANCE_RECOVERYDBA_HIST_JAVA_POOL_ADVICEDBA_HIST_THREAD - logswitches-DBA_HIST_STAT_NAMEDBA_HIST_SYSSTAT-DBA_HIST_SYS_TIME_MODEL-DBA_HIST_OSSTAT_NAME-DBA_HIST_OSSTATDBA_HIST_PARAMETER_NAMEDBA_HIST_PARAMETERDBA_HIST_UNDOSTATDBA_HIST_ROLLSTATDBA_HIST_SEG_STATDBA_HIST_SEG_STAT_OBJ-DBA_HIST_METRIC_NAME-DBA_HIST_SYSMETRIC_HISTORY alert-DBA_HIST_SYSMETRIC_SUMMARY max, min, avg standard deviation-DBA_HIST_SESSMETRIC_HISTORY alert-DBA_HIST_FILEMETRIC_HISTORY alert-DBA_HIST_WAITCLASSMET_HISTORY alertDBA_HIST_DLM_MISC-DBA_HIST_RCVRY_FILE_DEST_STAT-DBA_HIST_RMAN_PERFORMANCE-DBA_HIST_ACTIVE_SESS_HISTORY every 10th point from v$active_session_history-DBA_HIST_TABLESPACE_STAT-DBA_HIST_LOGDBA_HIST_MTTR_TARGET_ADVICE-DBA_HIST_TBSPC_SPACE_USAGE - ?New in 10g

  • ADDMMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • Automatic Database Diagnostic MonitorEvery Hour with AWRAnalyzeIdentify problemsProposes solutions

  • ADDM Page

  • ADDM Details

  • ADDM Advice

  • ADDM tablesdba_advisor_findings TASK_NAME, TASK_ID (is indexed)dba_advisor_recommendations TASK_ID,FINDING_IDdba_advisor_actions TASK_ID and REC_IDdba_advisor_rationale TASK_ID and REC_IDdba_advisor_objects TASK_ID , OBJECT_ID from actions or rationale.

  • ADDM tablesActions

    FindingsRecommendations

    objectsRationalAdd Free lists or move to ASSMSQLBBW:Read & write contention on a blockSegment TuningobjectsTables

  • Advisory Framework tablesActions

    FindingsRecommendations

    objectsRationalCould be just a message w/o command or rational Like investigate application logic22 types of which ADDM uses 7:SQLDATABASE OBJECT (Tables, Indexes, ...)TABLESPACEDATABASE BLOCKDATABASE FILEDATABASE LATCHDATABASE ENQADDM does not use this connection(maybe SQL Tuning Advisor )Types:PROBLEMSYMPTOMINFORMATIONTypes:Application AnalysisDB ConfigurationHost ConfigurationSQL Tuning Segment Tuning SchemaDoesnt use type

  • ADDM tables

  • MiscellaneousMetricsWait ClassesTime ModelASHAWR ( DBA_HIST_ )ADDMMiscPart IPart IIPart III

  • MiscellaneousField naming conventionsWait ImprovementsWait histogramsWaits in v$session and v$sqlWaits broken out for latches and locksWaits show the blockerWait history of last 10 waitsServicesClient Id

  • Fields NamesNamesEventStatisticWaitclassIds Event#Statistic#Waitclass#Name HashEvent_idStatistic_idWaitclass_id

  • Wait HistogramsV$event_histogram1ms to 1 hour buckets23 buckets< 1 ms, < 2 ms, < 4 ms, < 8 ms, ..., < 2^22 ms

  • Waits in v$session and v$sqlV$session exposes all the fields from v$session_wait SEQ# NUMBER EVENT# NUMBER EVENT VARCHAR2(64) P1TEXT VARCHAR2(64) P1 NUMBER P1RAW RAW(4) P2TEXT VARCHAR2(64) P2 NUMBER P2RAW RAW(4) P3TEXT VARCHAR2(64) P3 NUMBER P3RAW RAW(4) WAIT_CLASS_ID NUMBER WAIT_CLASS# NUMBER WAIT_CLASS VARCHAR2(64) WAIT_TIME NUMBER SECONDS_IN_WAIT NUMBER STATE VARCHAR2(19)

  • V$SQL SQL_FULLTEXT SQL_ID FETCHES END_OF_FETCH_COUNT DIRECT_WRITES APPLICATION_WAIT_TIME CONCURRENCY_WAIT_TIME CLUSTER_WAIT_TIME USER_IO_WAIT_TIME PLSQL_EXEC_TIME JAVA_EXEC_TIME CPU_TIME ELAPSED_TIME

  • Wait Types Broken Out800 waitsLatches broken outEx) Latch: library cache latchEnqueues broken outEx) Enq: HW - contention

  • Waits show Blocking SessionV$session. BLOCKING_SESSION -> can build a wait tree:

  • Waits History of last 10 waitsselect sid, event, p1,p2,p3 from v$session_wait_history SID EVENT P1 P2 P3---------- --------------------------- ---------- ---------- ---------- 36 db file sequential read 1 953 1 36 SQL*Net message from client 1413697536 1 0 36 SQL*Net message from client 1413697536 1 0 36 SQL*Net message to client 1413697536 1 0 36 db file sequential read 1 658 1 36 db file sequential read 1 828 1 36 db file sequential read 1 569 1 36 db file sequential read 1 827 1 36 db file sequential read 1 19199 1 36 db file sequential read 1 29 1

  • ServicesServices is a new way to measure resource usage and statistics. A session is associated with a services when the session connects to the database via the listener.

  • Client IdSetting Client ID dbms_session.set_identifier (client_id);Enabling trace for a client ID dbms_monitor.client_id_trace_enable (client_id, TRUE, FALSE);Enabling statistics aggregation by client id dbms_monitor.client_id_stat_enable (client_id);Script to Extract Client Trace trcsess

  • Session DedicatedOracle Database HostOracleSessionsS1S2S3S4S4S5S6ScottJohnSueMikeRandyTimMary

  • Session Dedicated traceOracle Database HostOracleSessionsS1S2S3S4S4S5S6ScottJohnSueMikeRandyTimMarySQL_TRACE=TRUE

  • Session Pooling traceOracle Database HostAPP Server 1OracleSessionsS1S2S3S4S4S5S6S7ScottJohnSueMikeRandyTimMaryS1, sql_trace=true

  • Session PoolingOracle Database HostAPP Server 1OracleSessionsS1S2S3S4S4S5S6S7ScottJohnSueMikeRandyTimMarySet client_id = SCOTT dbms_monitor.client_id_trace_enable (client_id, TRUE, FALSE); waits, binds

  • ------ Reference -------------

  • System Statistics View

    Stats ( V$stat_name)Waits ( V$event_name )Time ModelsqlRawV$sysstatv$system_eventv$event_histogram v$system_wait_class v$sys_time_model V$sqlNow

    V$sysmetric v$eventmetric v$waitclassmetric Some goes into sysmetricASHx$kewrtsqlstat 1 HourV$sysmetric_history V$sysmetric_summary v$waitclassmetric_history ASH

    7 days

    DBA_HIST_*SYSMETRIC_SUMMARY SYSSTAT(cumulative)SYSMETRIC_HISTORY (alerts)SYSTEM_EVENT (cumulative)WAITCLASSMETRIC_HISTORY (alert) SYS_TIME_MODEL(cumulative)SQLSTAT

  • Session Statistics View

    statswaitswaitclassesTime ModelsqlV$V$sessstatV$session_event----------------V$sess_time_model *-----------------(some stats possible from ASH)MetricsV$sessmetric--------------------------------------------------------------------Metricshistory----------------- --------------------------------------------------------------------AWRWRH$_SESSMETRIC_HISTORY *(alert only)-----------------(some stats possible from ASH) --------------------------------------------------(some stats possible from ASH)

  • V$metricv$metric BEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID ENTITY_ID session id, wait_class_id, etc ENTITY_SEQUENCE METRIC_ID METRIC_NAME VALUE METRIC_UNIT

  • Metric Group and v$metric 1* select * from v$metricgroup

    GID NAME INTS M_INT GROUP_ID COUNT(*)--- ----------------------------------- ------ ----- -------- ---------- 0 Event Metrics 6000 1 0 3 (per event) 1 Event Class Metrics 6000 60 1 4 (per waitclass) 2 System Metrics Long Duration 6000 60 2 114 3 System Metrics Short Duration 1500 12 3 40 4 Session Metrics Long Duration 6000 60 4 1 (blcoked user) 5 Session Metrics Short Duration 1500 1 5 8 (per session) 6 Service Metrics 6000 60 6 2 (per service) 7 File Metrics Long Duration 60000 6 7 6 (per file)

    2 is a superset of 34 is a superset of 5 Ie, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltasMax Interval

  • ASHASH provides two x$ fixed tables

    x$kewash - returns a row for every ASH sample takenx$ash- returns a row for every active session in every ASH sample

    SELECT /*+ no_merge ordered use_nl(s,a) */ a.inst_id, a.sample_id, a.sample_time, a.session_id, a.session_serial#, a.user_id, a.sql_id, a.sql_child_number, a.sql_plan_hash_value, a.sql_opcode, a.service_hash, decode(a.session_type, 1,'FOREGROUND', 2,'BACKGROUND', 'UNKNOWN'), decode(a.wait_time, 0, 'WAITING', 'ON CPU'), a.qc_session_id, a.qc_instance_id, a.seq#, a.event#, a.p1, a.p2, a.p3, a.wait_time, a.time_waited, a.current_obj#, a.current_file#, a.current_block#, a.program, a.module, a.action, a.client_id FROM x$kewash s, x$ash a WHERE s.sample_addr = a.sample_addr and s.sample_id = a.sample_id

    No range scans on x$ tables, so full scan x$kewash and then use equality in query on x$ash

  • X$ Desc x$ashSQL> desc x$kewash ADDR RAW(4) INDX NUMBER INST_ID NUMBER SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3) SAMPLE_ADDR NUMBER SAMPLE_LENGTH NUMBER ROW_COUNT NUMBER

    desc x$ash ADDR RAW(4) INDX NUMBER INST_ID NUMBER SAMPLE_ADDR NUMBER SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3) SESSION_ID NUMBER SESSION_SERIAL# NUMBER USER_ID NUMBER SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SERVICE_HASH NUMBER SESSION_TYPE NUMBER SQL_OPCODE NUMBER QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER SEQ# NUMBER EVENT# NUMBER P1 NUMBER P2 NUMBER P3 NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER PROGRAM VARCHAR2(48) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64)

  • Sql metrics: x$kewrtsqlstatx$kewrtsqlstat

  • ASH init.oraStatistics_level=typical_active_session_history=true

  • INIT.ORAASH _ash_enable = false; [ A dynamic parameter will turn off ASH sampling, flushing and the V$ views on ASH ] ADDM _addm_auto_enable = false; [ A dynamic parameter to turn off automatic ADDM runs after every AWR snapshot ] AWR "_swrf_mmon_flush" = FALSE ; AWR metrics "_swrf_mmon_metrics" = FALSE ; METRICS DB Feature Usage "_swrf_mmon_dbfus" = FALSE ; DB Feature Usage "_swrf_on_disk_enabled" = FALSE ; disable all (on disk, including manual) AWR operations:

  • EM Product Layout for PerformanceDatabase Home PageDatabase Performance PageDrilldownsSQLSession

  • EM Pages Layout

  • Buffer Busy Waits Use Case

  • Three Paths

  • ADDM Path

  • Database Home Page

  • ADDM Home

  • ADDM Home

  • ADDM Details

  • ADDM Details

  • Manual Path

  • Database Home Page

  • Database Home Page

  • Database Home Page

  • Performance Page

  • Database Performance Page

  • Database Performance Page highlight

  • Wait Drill Down

  • Wait Drill Down

  • Wait Drill Down

  • Wait Drill Down

  • Wait Drill Down highlight

  • Wait Drill Down Top SQL

  • SQL Details

  • SQL Details

  • Combined

  • Comparison

    To effectively diagnose performance problems, statistics must be available. Oracle generates many types of cumulative statistics for the system, sessions, and individual SQL statements. Oracle also tracks cumulative statistics on segments and services. When analyzing a performance problem in any of these scopes, you typically look at the change in statistics (delta value) over the period of time you are interested in. Specifically, you look at the difference between the cumulative value of a statistic at the start of the period and the cumulative value at the end. Cumulative values for statistics are generally available through dynamic performance views, such as the V$SESSTAT and V$SYSSTAT views. Note that the cumulative values in dynamic views are reset when the database instance is shutdown. The Automatic Workload Repository (AWR) automatically persists the cumulative and delta values for most of the statistics at all levels except the session level. This process is repeated on a regular time period and the result is called an AWR snapshot. The delta values captured by the snapshot represent the changes for each statistic over the time period. See "Automatic Workload Repository". Another type of statistic collected by Oracle is called a metric. A metric is defined as the rate of change in some cumulative statistic. That rate can be measured against a variety of units, including time, transactions, or database calls. For example, the number database calls per second is a metric. Metric values are exposed in some V$ views, where the values are the average over a fairly small time interval, typically 60 seconds. A history of recent metric values is available through V$ views, and some of the data is also persisted by AWR snapshots. A third type of statistical data collected by Oracle is sampled data. This sampling is performed by the active session history (ASH) sampler. ASH samples the current state of all active sessions. This data is collected into memory and can be accessed by a V$ view. It is also written out to persistent store by the AWR snapshot processing. See "Active Session History (ASH)".

    Some exceptionslogons currentopened cursors currentSome exceptionslogons currentopened cursors current10 minutes and 30 minutes in special cases10 minutes for File IO30 minutes for SQL metric values are constantly increasing in x$ until 30 minute snapshot when it is externalized into dba_hist_sqlstat SQL is a separate thing from metrics. Metrics are all stored in the same base x$ structure

    V$sysmetric is not a 1 to 1 map of v$sysstat, there are some new values and reduced set of systats made into per sec and per transaction metrics

    V$METRICV$METRIC_HISTORY

    Combined view onto the other metric tables

    V$METRICGROUPV$METRICNAME

    V$SYSMETRICV$SESSMETRICV$FILEMETRICV$EVENTMETRICV$WAITCLASSMETRICV$SVCMETRIC

    V$SYSMETRIC_HISTORYV$FILEMETRIC_HISTORYV$WAITCLASSMETRIC_HISTORYV$SVCMETRIC_HISTORY

    V$SYSMETRIC_SUMMARY

    10 minutes and 30 minutes in special cases10 minutes for File IO30 minutes for SQL metric values are constantly increasing in x$ until 30 minute snapshot when it is externalized into dba_hist_sqlstat SQL is a separate thing from metrics. Metrics are all stored in the same base x$ structure

    V$sysmetric is not a 1 to 1 map of v$sysstat, there are some new values and reduced set of systats made into per sec and per transaction metrics

    V$METRICV$METRIC_HISTORY

    Combined view onto the other metric tables

    V$METRICGROUPV$METRICNAME

    V$SYSMETRICV$SESSMETRICV$FILEMETRICV$EVENTMETRICV$WAITCLASSMETRICV$SVCMETRIC

    V$SYSMETRIC_HISTORYV$FILEMETRIC_HISTORYV$WAITCLASSMETRIC_HISTORYV$SVCMETRIC_HISTORY

    V$SYSMETRIC_SUMMARY

    SQLx$kewrtsqlstat (30 minutes)Session V$sessmetricBEGIN_TIME END_TIME INTSIZE_CSEC SESSION_IDSESSION_SERIAL_NUM CPU PHYSICAL_READS PGA_MEMORY HARD_PARSES SOFT_PARSES PHYSICAL_READ_PCT LOGICAL_READ_PCTGroup ID2 is a superset of 34 is a superset of 5

    Event class metricsSQL> select metric_id, metric_name , metric_unit from v$metricname where group_id=0;METRIC_ID METRIC_NAME METRIC_UNIT--------- ---------------------------------------- -------------------- 0 Number of Sessions Waiting (Event) number of sessions 1 Total Time Waited cent-seconds 2 Total Wait Counts number of waits

    SQL> select metric_id, metric_name , metric_unit from v$metricname where group_id=1;METRIC_ID METRIC_NAME METRIC_UNIT--------- -------------------------------- -------------------- 1000 Average Users Waiting Counts # of users 1001 Database Time Spent Waiting (%) % 1003 Total Time Waited centi-seconds 1002 Total Wait Counts number of waits

    Session Metrics--------------------SQL> select group_id, metric_id, metric_name , metric_unit from v$metricname where group_id in (4,5);

    GROUP_ID METRIC_ID METRIC_NAME METRIC_UNIT-------- --------- ---------------------------------------- -------------------- 4 4000 Blocked User Session Count num of sessions 5 5000 User Transaction Count (Session) num of transactions 5 5001 CPU Time (Session) centi-seconds 5 5002 Physical Reads (Session) num of reads 5 5003 PGA Memory (Session) num of bytes 5 5004 Hard Parse Count (Session) num of parses 5 5005 Total Parse Count (Session) num of parses 5 5006 Physical Reads Ratio (Sess/Sys) % in % 5 5007 Logical Reads Ratio (Sess/Sys) % in %

    Service and File Metrics------------------------------SQL> select group_id, metric_id, metric_name , metric_unit from v$metricname where group_id in (6,7)GROUP_ID METRIC_ID METRIC_NAME METRIC_UNIT-------- --------- ---------------------------------------- ------------------------- 6 6000 Elapsed Time Per User Call Microseconds per call 6 6001 CPU Time Per User Call Microseconds per call 7 7000 Average File Read Time (Files-Long) centi-secs per read 7 7001 Average File Write Time (Files-Long) centi-secs per Write 7 7002 Physical Reads (Files-Long) counts 7 7003 Physical Writes (Files-Long) counts 7 7004 Physical Block Reads (Files-Long) counts 7 7005 Physical Block Writes (Files-Long) counts

    1* select * from v$metricgroup

    GID NAME INTS M_INT GROUP_ID COUNT(*)--- ----------------------------------- ------ ----- -------- ---------- 0 Event Metrics 6000 1 0 3 1 Event Class Metrics 6000 60 1 4 2 System Metrics Long Duration 6000 60 2 114 3 System Metrics Short Duration 1500 12 3 40 4 Session Metrics Long Duration 6000 60 4 1 5 Session Metrics Short Duration 1500 1 5 8 6 Service Metrics 6000 60 6 2 7 File Metrics Long Duration 60000 6 7 6

    Max IntervalIe, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltas

    Buffer Cache Hit Ratio Memory Sorts Ratio Redo Allocation Hit Ratio User Commits Percentage User Rollbacks Percentage Cursor Cache Hit Ratio Rows Per Sort Execute Without Parse Ratio Soft Parse Ratio User Calls Ratio Global Cache Average CR Get Time Global Cache Average Current Get Time Global Cache Blocks Corrupted Global Cache Blocks Lost Current Logons Count Current Open Cursors Count User Limit % SQL Service Response Time Database Wait Time Ratio Database CPU Time Ratio Row Cache Hit Ratio Row Cache Miss Ratio Library Cache Hit Ratio Library Cache Miss Ratio Shared Pool Free % PGA Cache Hit % Process Limit % Session Limit % Txns Per Logon

    Per Sec User Commits User Rollbacks User Transaction DBWR Checkpoints Background Checkpoints Network Traffic VolumePer TransactionResponse TimePer Second and Transaction Physical Reads Physical Writes Physical Reads Direct Physical Writes Direct Physical Reads Direct Lobs Physical Writes Direct Lobs Redo Generated Logons Open Cursors User Calls Recursive Calls Logical Reads Redo Writes Long Table Scans Total Table Scans Full Index Scans Total Index Scans Total Parse Count Hard Parse Count Parse Failure Count Disk Sort Enqueue Timeouts Enqueue Waits Enqueue Deadlocks Enqueue Requests DB Block Gets Consistent Read Gets DB Block Changes Consistent Read Changes CPU Usage CR Blocks Created CR Undo Records Applied User Rollback Undo Records Applied Leaf Node Splits Branch Node Splits PX downgraded 1 to 25% PX downgraded 25 to 50% PX downgraded 50 to 75% PX downgraded 75 to 99%WaitsV$WAITCLASSMETRIC_HISTORY ( 60 seconds)(V$SESSION_WAIT_HISTORY 10 events)(V$ACTIVE_SESSION_HISTORY 30minutes, roughly)

    SQL> select BEGIN_TIME,FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY;

    BEGIN_TI FILE_ID PHYSICAL_READS-------- ---------- --------------04:12:16 1 20804:12:16 2 60004:02:18 1 60004:02:18 2 18903:52:15 1 192203:52:15 2 208203:42:17 1 25703:42:17 2 61903:32:17 1 94503:32:17 2 120603:22:16 1 3212

    BEGIN_TI FILE_ID PHYSICAL_READS-------- ---------- --------------03:22:16 2 182903:12:16 1 164103:12:16 2 854

    Reduced set of stats, only:Buffer Cache Hit RatioMemory Sorts RatioExecute Without Parse RatioSoft Parse RatioDatabase CPU Time RatioLibrary Cache Hit RatioShared Pool Free %Txns Per LogonPer SecUser Transaction Per SecPer Sec and Per TransactionPhysical ReadsPhysical WritesPhysical Reads DirectRedo GeneratedLogonsUser CallsLogical ReadsRedo WritesTotal Table ScansFull Index ScansDB Block GetsConsistent Read GetsDB Block ChangesConsistent Read ChangesExecutions

    Check and see if there is overlapSQLDBA_HIST_SQLSTAT

    Alerts-DBA_HIST_SYSMETRIC_HISTORY - WRH$_SYSMETRIC_SUMMARY-DBA_HIST_SESSMETRIC_HISTORY-DBA_HIST_FILEMETRIC_HISTORY - WRH$_FILEMETRIC_HISTORY-DBA_HIST_WAITCLASSMET_HISTORY

    All values-DBA_HIST_SYSMETRIC_SUMMARY max, min, avg standard deviation-DBA_HIST_SYSTEM_EVENT - wrh$_system_event

    Buffer Cache Hit RatioMemory Sorts RatioExecute Without Parse RatioSoft Parse RatioDatabase CPU Time RatioLibrary Cache Hit RatioShared Pool Free %Txns Per LogonPer SecUser Transaction Per SecPer Sec and Per TransactionPhysical ReadsPhysical WritesPhysical Reads DirectRedo GeneratedLogonsUser CallsLogical ReadsRedo WritesTotal Table ScansFull Index ScansDB Block GetsConsistent Read GetsDB Block ChangesConsistent Read ChangesExecutions

    Buffer Cache Hit Ratio Memory Sorts Ratio Redo Allocation Hit Ratio User Commits Percentage User Rollbacks Percentage Cursor Cache Hit Ratio Rows Per Sort Execute Without Parse Ratio Soft Parse Ratio User Calls Ratio Global Cache Average CR Get Time Global Cache Average Current Get Time Global Cache Blocks Corrupted Global Cache Blocks Lost Current Logons Count Current Open Cursors Count User Limit % SQL Service Response Time Database Wait Time Ratio Database CPU Time Ratio Row Cache Hit Ratio Row Cache Miss Ratio Library Cache Hit Ratio Library Cache Miss Ratio Shared Pool Free % PGA Cache Hit % Process Limit % Session Limit % Txns Per Logon

    Per Sec User Commits User Rollbacks User Transaction DBWR Checkpoints Background Checkpoints Network Traffic VolumePer TransactionResponse TimePer Second and Transaction Physical Reads Physical Writes Physical Reads Direct Physical Writes Direct Physical Reads Direct Lobs Physical Writes Direct Lobs Redo Generated Logons Open Cursors User Calls Recursive Calls Logical Reads Redo Writes Long Table Scans Total Table Scans Full Index Scans Total Index Scans Total Parse Count Hard Parse Count Parse Failure Count Disk Sort Enqueue Timeouts Enqueue Waits Enqueue Deadlocks Enqueue Requests DB Block Gets Consistent Read Gets DB Block Changes Consistent Read Changes CPU Usage CR Blocks Created CR Undo Records Applied User Rollback Undo Records Applied Leaf Node Splits Branch Node Splits PX downgraded 1 to 25% PX downgraded 25 to 50% PX downgraded 50 to 75% PX downgraded 75 to 99%

    V$sessmetricBEGIN_TIME END_TIME INTSIZE_CSEC SESSION_ID SESSION_SERIAL_NUM CPU PHYSICAL_READS PGA_MEMORY HARD_PARSES SOFT_PARSES PHYSICAL_READ_PCT LOGICAL_READ_PCT

    SQL> desc v$eventmetric Name Null? Type ----------------------------------------- -------- ---------------------------- BEGIN_TIME DATE END_TIME DATE INTSIZE_CSEC NUMBER EVENT# NUMBER EVENT_ID NUMBER NUM_SESS_WAITING NUMBER TIME_WAITED NUMBER WAIT_COUNT NUMBER

    SQL> select 2 en.name name, 3 num_sess_waiting nsw, 4 time_waited, 5 wait_count 6 from 7 v$eventmetric em, 8 v$event_name en 9 where 10 wait_count > 0 11 and en.event# = em.event# 12 /

    NAME NSW TIME_WAITED WAIT_COUNT---------------------------------------- ---------- ----------- ----------pmon timer 1 5875 20process startup 0 13 1rdbms ipc message 7 41104 168control file sequential read 0 0 10control file parallel write 0 2 20log file parallel write 0 0 1SQL*Net message to client 0 0 47SQL*Net more data to client 0 1 4SQL*Net message from client 4 14721 47SQL*Net more data from client 0 0 1queue messages 2 12012 24Queue Monitor Wait 1 3000 1Queue Monitor Task Wait 0 0 1SQL> select BEGIN_TIME,FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY;BEGIN_TI FILE_ID PHYSICAL_READS-------- ---------- --------------04:12:16 1 20804:12:16 2 60004:02:18 1 60004:02:18 2 18903:52:15 1 192203:52:15 2 208203:42:17 1 25703:42:17 2 61903:32:17 1 94503:32:17 2 120603:22:16 1 321203:22:16 2 182903:12:16 1 164103:12:16 2 854

    V$METRICV$METRIC_HISTORY

    Combined view onto the other metric tables

    V$METRICGROUPV$METRICNAME

    V$SYSMETRICV$SESSMETRICV$FILEMETRICV$EVENTMETRICV$WAITCLASSMETRICV$SVCMETRIC

    V$SYSMETRIC_HISTORYV$FILEMETRIC_HISTORYV$WAITCLASSMETRIC_HISTORYV$SVCMETRIC_HISTORY

    V$SYSMETRIC_SUMMARY

    800 waits in 10gLatchs and locks have been broken out into their own waitsIelatch: redo copyenqueue: CISQL> select * from v$system_wait_class;WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED------------- ----------- -------------------- ----------- ----------- 1893977003 0 Other 11695 1873612 4217450380 1 Application 9316 850799 3290255840 2 Configuration 1949 2379 4166625743 3 Administrative 3 475 3875070507 4 Concurrency 184 634 3386400367 5 Commit 6260 1423 2723168908 6 Idle 1531734 530987091 2000153315 7 Network 127231 1709 1740759767 8 User I/O 1037623 16561 4108307767 9 System I/O 268085 150502

    SQL> column name format a20SQL> select 2 en.wait_class name, 3 average_waiter_count awc, 4 dbtime_in_wait dbt, 5 time_waited, 6 wait_count 7 from 8 v$waitclassmetric wcm, 9 ( select distinct wait_class#, wait_class from v$event_name) en 10 where 11 wcm.wait_class# = en.wait_class# 12 /

    NAME AWC DBT TIME_WAITED WAIT_COUNT-------------------- ---------- ---------- ----------- ----------Other 0 4 12 1Application 0 0 0 7Configuration 0 0 1 2Administrative 0 0 0 0Concurrency 0 0 0 0Commit 0 0 1 2Idle 17 0 104965 278Network 0 0 0 50User I/O 0 3 10 614System I/O 0 10 33 81Scheduler 0 0 0 0

    NAME AWC DBT TIME_WAITED WAIT_COUNT-------------------- ---------- ---------- ----------- ----------Cluster 0 0 0 0

    V$WAITCLASSMETRIC, V$WAITCLASSMETRIC_HISTORY CLASS_ID -> WAIT_CLASS_ID Add WAIT_CLASS# column

    When tuning an Oracle system, each component has its own set of statistics. To look at the system as a whole, it is necessary to have a common scale for comparisons. Because of this, most Oracle advisories and reports describe statistics in terms of time. In addition, the V$SESS_TIME_MODEL and V$SYS_TIME_MODEL views provide time model statistics. Using the common time instrumentation helps to identify quantitative effects on the database operations. The most important of the time model statistics is DB time. This statistics represents the total time spent in database calls and is a indicator of the total instance workload. It is calculated by aggregating the CPU and wait times of all sessions not waiting on idle wait events (non-idle user sessions). DB time is measured cumulatively from the time that the instance was started. Because DB time it is calculated by combining the times from all non-idle user sessions, it is possible that the DB time can exceed the actual time elapsed since the instance started up. For example, a instance that has been running for 30 minutes could have four active user sessions whose cumulative DB time is approximately 120 minutes. The objective for tuning an Oracle system could be stated as reducing the time that users spend in performing some action on the database, or simply reducing DB time. Other time model statistics provide quantitative effects (in time) on specific actions, such as logon operations and hard and soft parses.

    DB Time Amount of elapsed time (in microseconds) spent performing Database user-level calls. This does not include the time spent on instance background processes such as PMON. DB CPU Amount of CPU time (in microseconds) spent on database user-level calls. This does not include the CPU time spent on instance background processes such as PMON. background cpu time Amount of CPU time (in microseconds) consumed by database background processes. sequence load elapsed time Amount of elapsed time spent getting the next sequence number from the data dictionary. If a sequence is cached, then this is the amount of time spent replenishing the cache when it runs out. No time is charged when a sequence number is found in the cache. For non-cached sequences, some time will be charged for every nextval call. parse time elapsed Amount of elapsed time spent parsing SQL statements. It includes both soft and hard parse time. hard parse elapsed time Amount of elapsed time spent hard parsing SQL statements. sql execute elapsed time Amount of elapsed time SQL statements are executing. Note that for select statements this also includes the amount of time spent performing fetches of query results. connection management call elapsed time Amount of elapsed time spent performing session connect and disconnect calls. failed parse elapsed time Amount of time spent performing SQL parses which ultimately fail with some parse error. hard parse (sharing criteria) elapsed time Amount of elapsed time spent performing SQL hard parses when the hard parse resulted from not being able to share an existing cursor in the SQL cache. hard parse (bind mismatch) elapsed time Amount of elapsed time spent performing SQL hard parses when the hard parse resulted from bind type or bind size mismatch with an existing cursor in the SQL cache. PL/SQL execution elapsed time Amount of elapsed time spent running the PL/SQL interpreter. This does not include time spent recursively executing/parsing SQL statements or time spent recursively executing the Java VM. PL/SQL compilation elapsed time Amount of elapsed time spent running the PL/SQL compiler. inbound PL/SQL rpc elapsed time Time inbound PL/SQL remote procedure calls have spent executing. It includes all time spent recursively executing SQL and JAVA, and therefore is not easily related to "PL/SQL execution elapsed time". Java execution elapsed time Amount of elapsed time spent running the Java VM. This does not include time spent recursively executing/parsing SQL statements or time spent recursively executing PL/SQL.

    Session Time ModelSQL> select STAT_NAME, value from V$SESS_TIME_MODEL where sid=1;DB time 143DB CPU 290000background cpu time 0sequence load elapsed time 0parse time elapsed 0hard parse elapsed time 0sql execute elapsed time 0global cache cr block receive time 0global cache current block receive time 0global cache get time 0connection management call elapsed time 0failed parse elapsed time 0hard parse (sharing criteria) elapsed time 0hard parse (bind mismatch) elapsed time 0PL/SQL execution elapsed time 0inbound PL/SQL rpc elapsed time 0PL/SQL compilation elapsed time 0Java execution elapsed time 0bind/define call elapsed time 0cluster wait time 0concurrency wait time 0application wait time 0user I/O wait time 0

    System time modelSQL> select STAT_NAME, value from V$SYS_TIME_MODEL;DB time 3.9837E+10DB CPU 2.4055E+10background cpu time 2.1808E+10sequence load elapsed time 15939410parse time elapsed 451760577hard parse elapsed time 178851736sql execute elapsed time 3.6900E+10connection management call elapsed time 1045589383failed parse elapsed time 848439hard parse (sharing criteria) elapsed time 3347865hard parse (bind mismatch) elapsed time 1515268PL/SQL execution elapsed time 418089534inbound PL/SQL rpc elapsed time 0PL/SQL compilation elapsed time 37666077Java execution elapsed time 0bind/define call elapsed time 0

    2) parse time elapsed 3) hard parse elapsed time 4) hard parse (sharing criteria) elapsed time 5) hard parse (bind mismatch) elapsed time The V$ACTIVE_SESSION_HISTORY view provides sampled session activity in the instance. Active sessions are sampled every second and are stored in a circular buffer in SGA. Any session that is connected to the database and is waiting for an event that does not belong to the Idle wait class is considered as an active session. This includes any session that was on the CPU at the time of sampling. Each session sample is a set of rows and the V$ACTIVE_SESSION_HISTORY view returns one row for each active session per sample, returning the latest session sample rows first. Because the active session samples are stored in a circular buffer in SGA, the greater the system activity, the smaller the number of seconds of session activity that can be stored in the circular buffer. This means that the duration for which a session sample appears in the V$ view, or the number of seconds of session activity that is displayed in the V$ view, is completely dependent on the database activity. As part of the Automatic Workload Repository (AWR) snapshots, the content of V$ACTIVE_SESSION_HISTORY is also flushed to disk. Because the content of this V$ view can get quite large during heavy system activity, only a portion of the session samples is written to disk. By capturing only active sessions, a manageable set of data is represented with the size being directly related to the work being performed rather than the number of sessions allowed on the system. Using the Active Session History enables you to examine and perform detailed analysis on both current data in the V$ACTIVE_SESSION_HISTORY view and historical data in the DBA_HIST_ACTIVE_SESS_HISTORY view, often avoiding the need to replay the workload to gather additional performance tracing information. The data present in ASH can be rolled up on various dimensions that it captures, including the following: SQL identifier of SQL statement Object number, file number, and block number Wait event identifier and parameters Session identifier and session serial number Module and action name Client identifier of the session Service hash identifier

    Size of Ash--- Algorithm used to estimate ASH buffers size memory_quota = max(2% of sga_target, 5% of shared_pool_size); /* sga_target = 0 when AUTO SGA is OFF */ cpu_quota = 2MB * (# of CPUs); ash_size = min( cpu_quota, memory_quota ); ash_size = max( 1MB, ash_size); /* atleast 1MB */ ash_size = min( 128MB, ash_size); /* atmost 128MB */ ---Size of Ash--- Algorithm used to estimate ASH buffers size memory_quota = max(2% of sga_target, 5% of shared_pool_size); /* sga_target = 0 when AUTO SGA is OFF */ cpu_quota = 2MB * (# of CPUs); ash_size = min( cpu_quota, memory_quota ); ash_size = max( 1MB, ash_size); /* atleast 1MB */ ash_size = min( 128MB, ash_size); /* atmost 128MB */ ---

    Select session_id, session_serial# , count(*) , round((count(*)*100)/(5*60),0) "%", lpad('*',round((count(*)*10)/(5*60),0),'*') "Bar"from v$active_session_historywhere session_state= 'ON CPU' and SAMPLE_TIME > sysdate - (5/(24*60))group by session_id, session_serial#order by count(*) desc/Not doing multiple scans on v$sqlNot capturing as much data from v$sqlStatspack was based on thresholdsAWR is based on work done in the last intervalRecos can have actions 1, 2 and 3. But action1 will have only one command and one (or zero) objects attached to it. If a reco actually consists of 2 actions (like "increase parameeter "open_cursors" AND increase parameter "session_cached_cursors") that reco will have 2 actions associated with it. The semantics between multiple actions in a single reco is AND. The semantics between multiple recos in a single finding is OR. V$EVENT_HISTOGRAM V$EVENT_HISTOGRAM displays a histogram of the number of waits, the maximum wait, and total wait time on an event basis. The histogram has buckets of time intervals from < 1 ms, < 2 ms, < 4 ms, < 8 ms, ... < 2^21 ms, < 2^22 ms, = 2^22 ms. The histogram will not be filled unless the TIMED_STATISTICS initialization parameter is set to true. Column Datatype Description EVENT# NUMBER Event number EVENT VARCHAR2(64) Name of the Event WAIT_TIME_MILLI NUMBER Amount of time the bucket represents (in milliseconds). If the duration = num, then this column represents waits of duration < num that are not included in any smaller bucket. WAIT_COUNT NUMBER Number of waits of the duration belonging to the bucket of the histogram

    The wait histograms (from v$event_histogram) are a time based histograms for each wait event. The histogram consists of 23 buckets from 1ms to 1 hour ( 1,2,4, ..., 2^22), and each bucket contains the number of times a wait as lasted less than that amount of time and more than the previous bucket, for example, select * from v$event_histogram where event#=588; EVENT# EVENT WAIT_TIME_MILLI WAIT_COUNT ---------- ----------------------------------- --------------- ---------- 588 SQL*Net message from client 1 373 588 SQL*Net message from client 2 1936 588 SQL*Net message from client 4 792 588 SQL*Net message from client 8 416 588 SQL*Net message from client 16 64 588 SQL*Net message from client 32 58 588 SQL*Net message from client 64 6 588 SQL*Net message from client 128 6 588 SQL*Net message from client 256 2 588 SQL*Net message from client 512 5 588 SQL*Net message from client 1024 0 588 SQL*Net message from client 2048 1 588 SQL*Net message from client 4096 9 588 SQL*Net message from client 8192 21 588 SQL*Net message from client 16384 22 588 SQL*Net message from client 32768 19 588 SQL*Net message from client 65536 14 588 SQL*Net message from client 131072 7 588 SQL*Net message from client 262144 5 588 SQL*Net message from client 524288 2 588 SQL*Net message from client 1048576 3 588 SQL*Net message from client 2097152 3 588 SQL*Net message from client 4194304 1 SQL*Net message from client is the idle time where the Oracle connection (session) has no work to do. For example if you run SQLplus and then go get a coffee, the Oracle connected session is idle. Thus the histogram will count how many times you were idle and for how long. For an sqlplus connection this isn't very important, but for and automated application, this can be an indication of how much time the application is working verses how much time the database is working. Here is another example 292 db file sequential read 1 1170075 292 db file sequential read 2 1881 292 db file sequential read 4 726 292 db file sequential read 8 389 292 db file sequential read 16 393 292 db file sequential read 32 85 292 db file sequential read 64 57 292 db file sequential read 128 60 292 db file sequential read 256 31 292 db file sequential read 512 2 292 db file sequential read 1024 4 These waits are IO from disk. The first bucket represents 1ms IOs, which is impossibly quick. The explanation is that the IOs are coming from UNIX memory not from disk. This indicates that it might be better to increase the buffer cache since it would be better to have Oracle managing the caching of Oracle blocks than the OS, plus all the reads into the Oracle cache cost resources. The above table also shows slow IOs. There are 94 IO's above 32ms which is slow but compared to over 1 million IO waits is a very small percentage, but actually a large percentage of the wait time due to IO. And an even quicker one on 9i systems and above is: select row_wait_obj#, sw.event from v$session_wait sw, v$session s where sw.event in ('db file scattered read', 'db file sequential read') and sw.sid=s.sid And in 10g, the session wait data is all available in v$session, just: select row_wait_obj#, event from v$session s where event in ('db file scattered read', 'db file sequential read') > select > objd , > event > from > v$bh bh, > v$session_wait sw > where > file#=p1 and block#=p2 and > event in ('db file scattered read', 'db file sequential read'); Group ID2 is a superset of 34 is a superset of 5

    Event class metricsSQL> select metric_id, metric_name , metric_unit from v$metricname where group_id=0;METRIC_ID METRIC_NAME METRIC_UNIT--------- ---------------------------------------- -------------------- 0 Number of Sessions Waiting (Event) number of sessions 1 Total Time Waited cent-seconds 2 Total Wait Counts number of waits

    SQL> select metric_id, metric_name , metric_unit from v$metricname where group_id=1;METRIC_ID METRIC_NAME METRIC_UNIT--------- -------------------------------- -------------------- 1000 Average Users Waiting Counts # of users 1001 Database Time Spent Waiting (%) % 1003 Total Time Waited centi-seconds 1002 Total Wait Counts number of waits

    Session Metrics--------------------SQL> select group_id, metric_id, metric_name , metric_unit from v$metricname where group_id in (4,5);

    GROUP_ID METRIC_ID METRIC_NAME METRIC_UNIT-------- --------- ---------------------------------------- -------------------- 4 4000 Blocked User Session Count num of sessions 5 5000 User Transaction Count (Session) num of transactions 5 5001 CPU Time (Session) centi-seconds 5 5002 Physical Reads (Session) num of reads 5 5003 PGA Memory (Session) num of bytes 5 5004 Hard Parse Count (Session) num of parses 5 5005 Total Parse Count (Session) num of parses 5 5006 Physical Reads Ratio (Sess/Sys) % in % 5 5007 Logical Reads Ratio (Sess/Sys) % in %

    Service and File Metrics------------------------------SQL> select group_id, metric_id, metric_name , metric_unit from v$metricname where group_id in (6,7)GROUP_ID METRIC_ID METRIC_NAME METRIC_UNIT-------- --------- ---------------------------------------- ------------------------- 6 6000 Elapsed Time Per User Call Microseconds per call 6 6001 CPU Time Per User Call Microseconds per call 7 7000 Average File Read Time (Files-Long) centi-secs per read 7 7001 Average File Write Time (Files-Long) centi-secs per Write 7 7002 Physical Reads (Files-Long) counts 7 7003 Physical Writes (Files-Long) counts 7 7004 Physical Block Reads (Files-Long) counts 7 7005 Physical Block Writes (Files-Long) counts

    1* select * from v$metricgroup

    GID NAME INTS M_INT GROUP_ID COUNT(*)--- ----------------------------------- ------ ----- -------- ---------- 0 Event Metrics 6000 1 0 3 1 Event Class Metrics 6000 60 1 4 2 System Metrics Long Duration 6000 60 2 114 3 System Metrics Short Duration 1500 12 3 40 4 Session Metrics Long Duration 6000 60 4 1 5 Session Metrics Short Duration 1500 1 5 8 6 Service Metrics 6000 60 6 2 7 File Metrics Long Duration 60000 6 7 6

    Max IntervalIe, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltas

    ASH _ash_enable = false; [ A dynamic parameter will turn off ASH sampling, flushing and the V$ views on ASH ] _ash_enable = false; [ A dynamic parameter will turn off ASH sampling, flushing and the V$ views on ASH ] _ash_enable = false; [ A dynamic parameter will turn off ASH sampling, flushing and the V$ views on ASH ] ADDM _addm_auto_enable = false; [ A dynamic parameter to turn off automatic ADDM runs after every AWR snapshot ] AWR "_swrf_mmon_flush" = FALSE ; AWR metrics "_swrf_mmon_metrics" = FALSE ; METRICS DB Feature Usage "_swrf_mmon_dbfus" = FALSE ; DB Feature Usage "_swrf_on_disk_enabled" = FALSE ; disable all (on disk, including manual) AWR operations: