10g New Performance Features 1. 2. 3. 4. Metrics AWR ( DBA_HIST_ ) Time Model Wait Classes 5. Misc 1. 2. 3. 4. V$sqlstats Wait improvements Client_id Services Copyright 2006 Kyle Hailey #.1 #.2 9i Waits v$system_event v$sql V$system_event V$sql – includes stats V$session_wait V$session_event V$sesstat v$sysstat v$session Copyright 2006 Kyle Hailey #.3 10g Waits SQL V$sql V$session Stats Sessions Includes some waits now Copyright 2006 Kyle Hailey #.4 Metrics – rates and calculations DBA_HIST_SQLSTAT Waits SQL V$eventmetric V$waitclassm etric Metrics Stats Sessions V$sysmetric Copyright 2006 Kyle Hailey V$sessmetric #.5 Metrics What inspired Metrics? Old statistics were cumulative Old statistics lacked history … a new 10g feature to make our lives easier What is the IO on the system right now? Copyright 2006 Kyle Hailey #.6 First Tedious Step Select value from v$sysstat where name=‘physical reads’; VALUE --------------1,533,787 Not much help …Why? Let see … Copyright 2006 Kyle Hailey #.7 This tells you … Nothing GOOD BAD 1,533,787 30 minutes IO’s 30 minutes time time Copyright 2006 Kyle Hailey #.8 YOU Need to do MATH to find Out Take value at time A Take value at time B Delta = (B-A) or Rate = (B-A)/elapsed time Copyright 2006 Kyle Hailey Methods Oracle 6 Utlbstat.sql/Utlestat.sql Creates tables, inserts, deletes Oracle 8 introduced Statspack Improvement, but needs to be set up and administered (by guess who) Oracle 10 introduces Metrics (and AWR & OEM) Copyright 2006 Kyle Hailey #.9 #.10 Performance Metric Deltas Kinds of Metric Tables 1. Metric – current deltas 2. Metric History – deltas over last hour Current Deltas Values over last hour V$EVENTMETRIC V$FILEMETRIC V$SESSMETRIC V$SERVICEMETRIC V$SYSMETRIC V$SYSMETRIC_SUMMARY V$WAITCLASSMETRIC V$FILEMETRIC_HISTORY V$SYSMETRIC_HISTORY V$SERVICEMETRIC_HISTORY V$WAITCLASSMETRIC_HISTORY Copyright 2006 Kyle Hailey #.11 Metrics Collected at Pre-Set intervals 15 second 60 second 10 minutes 30 minutes Current Value for Deltas Rates per second per transaction Ratios Percentages dependability at your fingertips Copyright 2006 Kyle Hailey #.12 Metric Tables Wait Events V$EVENTMETRIC (60 secs ) V$WAITCLASSMETRIC (60 secs) Statistics V$SESSMETRIC (15 secs Deltas) V$SYSMETRIC (15 and 60 secs deltas) Files V$FILEMETRIC ( 10 minutes) SQL (the secret is out) x$kkssqlsta (30 Minutes) “not a metric” cumulates values up to 30 minutes, then snapshots it to dba_hist_sqlstat Copyright 2006 Kyle Hailey #.13 Answer at your fingertips GOOD BAD 3 IO/sec X 1,533,787 513 IO/sec 30 minutes IO’s 30 minutes time time Copyright 2006 Kyle Hailey #.14 Now What’s the IO? Select VALUE , METRIC_UNIT from v$sysmetric where metric_name='Physical Reads Per Sec‘; VALUE METRIC_UNIT INTSIZE_CSEC ---------- ----------------- -----------654.6736 Reads Per Second 5959 134.9835 Reads Per Second 1515 Avg IO per sec for the last 15 and 60 secs Copyright 2006 Kyle Hailey #.15 v$sysmetric desc v$sysmetric BEGIN_TIME END_TIME INTSIZE_CSEC – interval value in 1/100sec GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNIT Attention: metric_names are different from v$sysstat Copyright 2006 Kyle Hailey v$sysmetric 15 Secs Buffer Cache Hit Ratio Memory Sorts Ratio Execute Without Parse Ratio Soft Parse Ratio Database CPU Time Ratio Library Cache Hit Ratio Shared Pool Free % Txns Per Logon Per Sec User Transaction Per Sec Per Sec and Per Transaction Physical Reads Physical Writes Physical Reads Direct Redo Generated Logons User Calls Logical Reads Redo Writes Total Table Scans Full Index Scans DB Block Gets Consistent Read Gets DB Block Changes Consistent Read Changes Executions Copyright 2006 Kyle Hailey #.16 v$sysmetric 60 Sec 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 Copyright 2006 Kyle Hailey #.17 v$sysmetric 60 Sec #.18 Per Second and Transaction Per Sec User Commits User Rollbacks User Transaction DBWR Checkpoints Background Checkpoints Network Traffic Volume Per Transaction Response Time 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 Copyright 2006 Kyle Hailey 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% . #.19 v$sessmetric desc v$sessmetric BEGIN_TIME END_TIME • Only 15 second Delta INTSIZE_CSEC SESSION_ID SESSION_SERIAL_NUM CPU PHYSICAL_READS PGA_MEMORY HARD_PARSES SOFT_PARSES PHYSICAL_READ_PCT LOGICAL_READ_PCT Copyright 2006 Kyle Hailey #.20 Desc v$eventmetric SQL> desc v$eventmetric Name ---------------------------------BEGIN_TIME END_TIME INTSIZE_CSEC EVENT# EVENT_ID NUM_SESS_WAITING TIME_WAITED WAIT_COUNT Copyright 2006 Kyle Hailey Type -----DATE DATE NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER #.21 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# / Copyright 2006 Kyle Hailey v$eventmetric results #.22 NAME WAITERS TIME_WAITED WAIT_COUNT ------------------------------ ------- ----------- --------pmon timer 1 5875 20 process startup 0 13 1 rdbms ipc message 7 41104 168 control file sequential read 0 0 10 control file parallel write 0 2 20 log file parallel write 0 0 1 SQL*Net message to client 0 0 47 SQL*Net more data to client 0 1 4 SQL*Net message from client 4 14721 47 SQL*Net more data from client 0 0 1 queue messages 2 12012 24 Queue Monitor Wait 1 3000 1 Queue Monitor Task Wait 0 0 1 Copyright 2006 Kyle Hailey #.23 Historical Metrics We solved what’s 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 Copyright 2006 Kyle Hailey #.24 Historical Metrics v$sysstat physical reads Low rate Little IO High rate Lots of IO Copyright 2006 Kyle Hailey #.25 Metric History Tables Last 60 minutes of history, in memory v$sysstat physical reads delta delta delta delta delta delta delta 60 secs 60 secs 60 secs 60 secs 60 secs 60 secs Copyright 2006 Kyle Hailey 60 secs #.26 Metric History Tables Last hour of statistics at your fingertips : Statistics V$SYSMETRIC_HISTORY 60 seconds for an hour 3 minutes of 15 second File IO V$FILEMETRIC_HISTORY 10 minutes for an hour Waits V$WAITCLASSMETRIC_HISTORY 60 seconds for an hour Copyright 2006 Kyle Hailey #.27 v$sysmetric_history 3 minutes of 15 second deltas 60 minutes of 1 minute deltas Not saved to disk but summary is Copyright 2006 Kyle Hailey #.28 What was IO 30 minutes ago? Once again the answer is at your fingertips Select to_char(end_time,'DD-MON-YY HH24:MI'), VALUE , METRIC_UNIT from v$sysmetric_history where METRIC_NAME = 'Physical Reads Per Sec' and END_TIME < ( sysdate - (30/(24*60))) and END_TIME > ( sysdate - (35/(24*60))) TO_CHAR(END_TIM VALUE order by end_time; --------------- ---------08-JAN-08 08-JAN-08 08-JAN-08 08-JAN-08 08-JAN-08 11:38 118.65 11:39 76.6166667 11:40 3.44770153 11:41 28.7 11:42 19.6166667 Copyright 2006 Kyle Hailey METRIC_UNIT ---------------Reads Per Second Reads Per Second Reads Per Second Reads Per Second Reads Per Second #.29 V$FILEMETRIC_HISTORY select from BEGIN_TIME, FILE_ID, PHYSICAL_READS V$FILEMETRIC_HISTORY; BEGIN_TI FILE_ID PHYSICAL_READS -------- ---------- -------------04:12:16 1 208 04:12:16 2 600 Physical Reads 04:02:18 04:02:18 1 2 600 189 file 03:52:15 03:52:15 1 2 1922 2082 … Copyright 2006 Kyle Hailey Broken down by #.30 Metrics Family of Tables Stats Waits Files SQL Raw V$sysstat v$system_event v$event_histogram v$system_wait_class v$fileio v$sqlstat Deltas V$sysmetric V$SYSMETRIC V$SYSMETRIC_SUMMARY V$SESSMETRIC v$eventmetric v$waitclassmetric v$filemetric v$kkssqlsta V$sysmetric_history V$sysmetric_summary v$waitclassmetric_history v$filemetric_history (v$kkssqlsta) 1 Hour 7 days DBA_HIST_ SYSMETRIC_SUMMARY DBA_HIST_SQLSTAT Copyright 2006 Kyle Hailey Session Statistics View stats waits waitclasses sql V$ V$sessstat V$session_event ---------------- ----------------(some stats possible from ASH) Metrics V$sessmetric ----------------- ----------------- ----------------- Metrics ----------------- ----------------- ----------------- ----------------- ----------------(some stats possible from ASH) ---------------- ----------------(some stats possible from ASH) history AWR WRH$_SESSMET RIC_HISTORY * (alert only) Copyright 2006 Kyle Hailey #.31 Metric Alerts If Alerts fire on Metrics, then the deltas are kept in historical table for 7 days by default Statistics DBA_HIST_SYSMETRIC_HISTORY DBA_HIST_SESSMETRIC_HISTORY Waits WAITCLASSMETRIC_HISTORY File IO DBA_HIST_FILEMETRIC_HISTORY Copyright 2006 Kyle Hailey #.32 Metrics Family of Tables Stats Waits Files Raw V$sysstat v$system_event v$event_histogram v$system_wait_class v$fileio Now V$sysmetric V$SYSMETRIC V$SYSMETRIC_SUMMARY V$SESSMETRIC v$eventmetric v$waitclassmetric v$filemetric V$sysmetric_history V$sysmetric_summary v$waitclassmetric_history v$filemetric_history DBA_HIST_ DBA_HIST_ WAITCLASSMETRIC_HISTORY DBA_HIST_ 1 Hour 7 days Alerts only SYSMETRIC_HISTORY DBA_HIST_ SESSMETRIC_HISTORY Copyright 2006 Kyle Hailey FILEMETRIC_HISTORY #.33 #.34 AWR Automatic Workload Repository Statspack on Steroids More efficient than Statspack More in memory Less latching Keeps stats every hour Stores by default the last 7 days Copyright 2006 Kyle Hailey #.35 Snapshoting Done automatically out of the box, but can be run by hand: BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END; / Copyright 2006 Kyle Hailey DBA_HIST #.36 DBA_HIST_RESOURCE_LIMIT dbms_workload_repository.drop_snapshot_range DBA_HIST_SHARED_POOL_ADVICE DBA_HIST_DATABASE_INSTANCE DBA_HIST_SNAPSHOT - DBA_HIST_SNAP_ERROR - DBA_HIST_BASELINE - DBA_HIST_WR_CONTROL ? (work load repository ?) - DBA_HIST_DATAFILE DBA_HIST_FILESTATXS – only file number, no name - DBA_HIST_TEMPFILE DBA_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_SQLBIND_META - WRH$_SQL_BIND_METADATA -DBA_HIST_OPTIMIZER_ENV -DBA_HIST_EVENT_NAME DBA_HIST_SYSTEM_EVENT DBA_HIST_BG_EVENT_SUMMARY – sum of backgrounds DBA_HIST_WAITSTAT DBA_HIST_ENQUEUE_STAT -DBA_HIST_LATCH_NAME DBA_HIST_LATCH DBA_HIST_LATCH_CHILDREN DBA_HIST_LATCH_PARENT DBA_HIST_LATCH_MISSES_SUMMARY – summed over parent latch DBA_HIST_LIBRARYCACHE DBA_HIST_DB_CACHE_ADVICE DBA_HIST_BUFFER_POOL_STAT DBA_HIST_ROWCACHE_SUMMARY – summed over rowcache entries DBA_HIST_SGA DBA_HIST_SGASTAT DBA_HIST_PGASTAT New in 10g ?DBA_HIST_SQL_WORKAREA_HSTGRM DBA_HIST_PGA_TARGET_ADVICE DBA_HIST_INSTANCE_RECOVERY DBA_HIST_JAVA_POOL_ADVICE DBA_HIST_THREAD - logswitches -DBA_HIST_STAT_NAME DBA_HIST_SYSSTAT -DBA_HIST_SYS_TIME_MODEL -DBA_HIST_OSSTAT_NAME -DBA_HIST_OSSTAT DBA_HIST_PARAMETER_NAME DBA_HIST_PARAMETER DBA_HIST_UNDOSTAT DBA_HIST_ROLLSTAT DBA_HIST_SEG_STAT DBA_HIST_SEG_STAT_OBJ – object name -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 alert DBA_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_LOG DBA_HIST_MTTR_TARGET_ADVICE -DBA_HIST_TBSPC_SPACE_USAGE - ? Copyright 2006 Kyle Hailey Retention and Interval #.37 Defaults: Hourly snapshots 7 days saved SELECT retention, snap_interval FROM wrm$_wr_control; RETENTION SNAP_INTERVAL ----------------- -----------------+00007 00:00:00.0 +00000 01:00:00.0 Minutes exec dbms_workload_repository.modify_snapshot_settings(14*24*60,30); RETENTION SNAP_INTERVAL ----------------- ----------------+00014 00:00:00.0 +00000 00:30:00.0 Copyright 2006 Kyle Hailey #.38 AWR RPT @?/rdbms/admin/awrrpt.sql Creates Report File Similar to STATSPACK report More efficient and more data HTML or TEXT Copyright 2006 Kyle Hailey AWR Report Can also be run SELECT * FROM TABLE( dbms_workload_repository.awr_report_text( (select dbid from v$database), 1, 124, -- begin id 125 -- end id )) Copyright 2006 Kyle Hailey #.39 #.40 AWR Report 1) 2) 3) 4) 5) 6) 7) 8) 9) 10) General info Load Profile Wait Events OS Stats Service Stats Top SQL by sql_id SQL Text Instance Statistic I/O Stat Buffer Pool Stats 11) Advisories 1) Buffer pool 2) PGA 3) Shared Pool 4) SGA 5) Streams 6) Java Copyright 2006 Kyle Hailey 12) Buffer Pool Stats 13) Wait Stats 1) Buffer Busy 2) Enqueues 14) Undo Stats 15) Latch Stats 16) Segment Stats 17) Dictionary Stats 18) Library Cache 19) Memory SGA/PGA 20) Streams 21) Init.ora #.41 Awr 1-13 Copyright 2006 Kyle Hailey #.42 AWR 14-26 Copyright 2006 Kyle Hailey AWR Diff SELECT * FROM TABLE( dbms_workload_repository.awr_diff_report_text( (select dbid from v$database), 1, 120, 121, (select dbid from v$database), 1, 122, 123) ); Also : AWR_DIFF_REPORT_HTML Copyright 2006 Kyle Hailey #.43 #.44 AWR Diff Report in OEM NOTE: Package AWR_DIFF_REPORT_HTML Is different from OEM Its just a tabular output Copyright 2006 Kyle Hailey #.45 Also, ADDM report by Hand select dbms_advisor.get_task_report(task_name) from dba_advisor_tasks where task_id = ( select max(t.task_id) from dba_advisor_tasks t, dba_advisor_log l where t.task_id = l.task_id and t.advisor_name = 'ADDM' and l.status = 'COMPLETED'); Set long 100000 Maximum is is 2,000,000,000 bytes . Copyright 2006 Kyle Hailey #.46 Important AWR Tables DBA_HIST_SQLSTAT SQL deltas DBA_HIST_SEG_STAT Segment deltas DBA_HIST_SYSMETRIC_SUMMARY Stats, max, min, avg DBA_HIST_ACTIVE_SESS_HISTORY ASH DBA_HIST_SYSTEM_EVENT Waits dba_hist_sqltext – get sql text from AWR Copyright 2006 Kyle Hailey DBA_HIST_SNAPSHOT SQL> desc DBA_HIST_SNAPSHOT Name ------------------SNAP_ID DBID INSTANCE_NUMBER STARTUP_TIME BEGIN_INTERVAL_TIME END_INTERVAL_TIME FLUSH_ELAPSED SNAP_LEVEL ERROR_COUNT Type ----------------------NUMBER NUMBER NUMBER TIMESTAMP(3) TIMESTAMP(3) TIMESTAMP(3) INTERVAL DAY(5) TO SECOND(1) NUMBER NUMBER Copyright 2006 Kyle Hailey #.47 DBA_HIST_SQLSTAT SNAP_ID DBID INSTANCE_NUMBER SQL_ID PLAN_HASH_VALUE OPTIMIZER_COST OPTIMIZER_MODE OPTIMIZER_ENV_HASH_VALUE SHARABLE_MEM LOADED_VERSIONS VERSION_COUNT MODULE ACTION SQL_PROFILE FORCE_MATCHING_SIGNATURE PARSING_SCHEMA_ID PARSING_SCHEMA_NAME BIND_DATA FETCHES_DELTA END_OF_FETCH_COUNT_DELTA SORTS_DELTA EXECUTIONS_DELTA PX_SERVERS_EXECS_DELTA LOADS_DELTA INVALIDATIONS_DELTA PARSE_CALLS_DELTA DISK_READS_DELTA BUFFER_GETS_DELTA ROWS_PROCESSED_DELTA CPU_TIME_DELTA ELAPSED_TIME_DELTA IOWAIT_DELTA CLWAIT_DELTA APWAIT_DELTA CCWAIT_DELTA DIRECT_WRITES_DELTA PLSEXEC_TIME_DELTA JAVEXEC_TIME_DELTA Copyright 2006 Kyle Hailey #.48 DBA_HIST_SEG_STAT SQL> desc DBA_HIST_SEG_STAT PHYSICAL_WRITES_TOTAL Name ------------------------------- PHYSICAL_WRITES_DELTA SNAP_ID PHYSICAL_READS_DIRECT_TOTAL DBID PHYSICAL_READS_DIRECT_DELTA INSTANCE_NUMBER PHYSICAL_WRITES_DIRECT_TOTAL TS# PHYSICAL_WRITES_DIRECT_DELTA OBJ# ITL_WAITS_TOTAL DATAOBJ# ITL_WAITS_DELTA LOGICAL_READS_TOTAL ROW_LOCK_WAITS_TOTAL LOGICAL_READS_DELTA ROW_LOCK_WAITS_DELTA BUFFER_BUSY_WAITS_TOTAL SPACE_USED_TOTAL BUFFER_BUSY_WAITS_DELTA SPACE_USED_DELTA DB_BLOCK_CHANGES_TOTAL SPACE_ALLOCATED_TOTAL DB_BLOCK_CHANGES_DELTA SPACE_ALLOCATED_DELTA PHYSICAL_READS_TOTAL TABLE_SCANS_TOTAL PHYSICAL_READS_DELTA TABLE_SCANS_DELTA Copyright 2006 Kyle Hailey #.49 ITL Waits #.50 select begin_interval_time, o.name, itl_waits_delta itl from DBA_HIST_SEG_STAT ss, DBA_HIST_SNAPSHOT sn, obj$ o where o.obj# = ss.obj# and itl_waits_delta > 10 and sn.snap_id=ss.snap_id; BEGIN --------------06-JAN-08 10:00 06-JAN-08 01:00 06-JAN-08 19:00 Copyright 2006 Kyle Hailey NAME ITL ---------- ----ITL 24 ITL 40 T1_I1 2071 #.51 DBA_HIST_SYSTEM_EVENT SQL> desc DBA_HIST_SYSTEM_EVENT Name Type ---------------------------------SNAP_ID NUMBER DBID NUMBER INSTANCE_NUMBER NUMBER EVENT_ID NUMBER EVENT_NAME VARCHAR2(64) WAIT_CLASS_ID NUMBER WAIT_CLASS VARCHAR2(64) TOTAL_WAITS NUMBER TOTAL_TIMEOUTS NUMBER TIME_WAITED_MICRO NUMBER Cumulative Values – can use LAG function Copyright 2006 Kyle Hailey #.52 Average Wait Times select btime, (time_ms_end-time_ms_beg)/nullif(count_end-count_beg,0) avg_ms from ( select to_char(s.BEGIN_INTERVAL_TIME,'DD-MON-YY HH24:MI') btime, total_waits count_end, time_waited_micro/1000 time_ms_end, Lag (e.time_waited_micro/1000) OVER( PARTITION BY e.event_name ORDER BY s.snap_id) time_ms_beg, Lag (e.total_waits) OVER( PARTITION BY e.event_name ORDER BY s.snap_id) count_beg from DBA_HIST_SYSTEM_EVENT e, BTIME AVG_MS DBA_HIST_SNAPSHOT s -------------------- -----------where 08-JAN-08 01:00 1.017 s.snap_id=e.snap_id 08-JAN-08 02:00 .720 and e.event_name= '&1' 08-JAN-08 03:00 .621 order by begin_interval_time 08-JAN-08 04:00 1.747 ) 08-JAN-08 05:00 1.046 order by btime; 08-JAN-08 06:00 Copyright 2006 Kyle Hailey 1.444 #.53 ASH RPT @?/rdbms/admin/ashrpt Detailed report on top SQL, Sessions, Objects etc Run over SQL*Net with select output from table(dbms_workload_repository.ash_report_text( (select dbid from v$database), 1, sysdate – 2/24, sysdate – 1/24, 0)) ; Also ASH_REPORT_HTML Copyright 2006 Kyle Hailey #.54 ASH RPT 1) General info 2) Top User Events *** 3) Top Background Events 4) Top Event P1/P2/P3 Values 5) Top Service/Module 6) Top Client IDs 7) Top SQL Command Types 8) Top SQL Statements *** 9) Top SQL using literals 10) Top Sessions *** 11) Top Blocking Sessions 12) Top Sessions running PQs 13) Top DB Objects 14) Top DB Files 15) Top Latches 16) Activity Over Time *** Copyright 2006 Kyle Hailey #.55 ASH RPT HTML Copyright 2006 Kyle Hailey #.56 Time Model New concept • DB Time Total time for all database calls • cpu time • wait time Copyright 2006 Kyle Hailey Time Model Time Model SQL Wait Metrics Stats Sessions Copyright 2006 Kyle Hailey #.57 #.58 Time Model areas Total Time CPU Elapsed Time SQL execution Plsql execution (sql execute subtracted out) Java execution Connection time Probably the most important as it points out problems with too many logons/sec Copyright 2006 Kyle Hailey Time Model Components 1) 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 Copyright 2006 Kyle Hailey #.59 #.60 Total Time Total Database Time Copyright 2006 Kyle Hailey #.61 Total and CPU =~ DB Wait Time DB CPU Time Copyright 2006 Kyle Hailey #.62 Total and CPU and Parse Time DB CPU Time DB Wait Time Parse Elapsed Time Copyright 2006 Kyle Hailey #.63 Parse Time Parse Elapsed Time Copyright 2006 Kyle Hailey #.64 Hard Parse Parse time elapsed Copyright 2006 Kyle Hailey hard parse elapse d time #.65 Hard Parse Sharing Criteria Parse time elapsed hard parse elapse d time Copyright 2006 Kyle Hailey hard parse (sharing criteria) elapsed time #.66 Hard Parse Bind Mismatch Parse time elapsed hard parse hard (sharing parse criteria) elapse elapsed d time time Copyright 2006 Kyle Hailey hard parse (bind mismat ch) elapsed time #.67 Time Model Tables Current cumulative values V$SYS_TIME_MODEL V$SESS_TIME_MODEL AWR Snapshots of cumulative values DBA_HIST_SYS_TIME_MODEL Tables show cumulative values. To find deltas, then need to run AWR report Copyright 2006 Kyle Hailey #.68 Wait Classes Administrative (39) switch logfile rebuild index Application (11) enqueues sqlnet break/reset Cluster (113) Commit (1) Log file Sync Concurrency (12) Latches: cbc, lbc, Lib cache locks Buffer busy wait Configuration (20) log file size Enqueues: ST, HW, ITL Latch: redo copy,shared pool Idle (56) Network (25) System I/O (19) Scheduler (6) User I/O (12) Other (485) Copyright 2006 Kyle Hailey #.69 Wait Class Tables v$system_wait_class cumulative v$waitclassmetric Current rates v$waitclassmetric_history Hour of rates (60 second intervals) Copyright 2006 Kyle Hailey Waits Metrics Cumulative Current deltas Last Hour v$waitclassmetric v$waitclassmetric_history BEGIN_TIME BEGIN_TIME END_TIME END_TIME INTSIZE_CSEC INTSIZE_CSEC WAIT_CLASS_ID WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS# NUM_SESS_WAITING NUM_SESS_WAITING TIME_WAITED TIME_WAITED WAIT_COUNT WAIT_COUNT #.70 Last 7 days Wait Classes v$system_wait_class WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED v$event_name EVENT# dba_hist_ waitclassmetric_history Only gets populated with alerts EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS Wait Events v$system_event EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT TIME_WAITED_MICRO EVENT_ID v$eventmetric BEGIN_TIME END_TIME INTSIZE_CSEC EVENT_ID NUM_SESS_WAITING TIME_WAITED WAIT_COUNT dba_hist_system_event (Cumulative) No in memory history Copyright 2006 Kyle Hailey #.71 Miscellaneous V$sqlstats Field naming conventions Wait Improvements Wait histograms Waits in v$session and v$sql Waits broken out for latches and locks Waits show the blocker Wait history of last 10 waits Services Client Id Copyright 2006 Kyle Hailey #.72 v$sqlstats More efficient than v$sql or v$sqlarea Skips many of the latch gets that v$sql does Copyright 2006 Kyle Hailey #.73 Event and Stat Fields Names Names Event Statistic Waitclass Ids Event# Statistic# Waitclass# Name Hash Event_id Statistic_id Waitclass_id Copyright 2006 Kyle Hailey #.74 Wait Histograms V$event_histogram 1ms to 1 hour buckets 23 buckets < 1 ms, < 2 ms, < 4 ms, < 8 ms, ..., < 2^22 ms Copyright 2006 Kyle Hailey #.75 Waits in v$session V$session exposes all the fields from v$session_wait SEQ# EVENT# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAW WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS WAIT_TIME SECONDS_IN_WAIT STATE NUMBER NUMBER VARCHAR2(64) VARCHAR2(64) NUMBER RAW(4) VARCHAR2(64) NUMBER RAW(4) VARCHAR2(64) NUMBER RAW(4) NUMBER NUMBER VARCHAR2(64) NUMBER NUMBER VARCHAR2(19) Copyright 2006 Kyle Hailey Waits in V$SQL SQL_FULLTEXT SQL_ID FETCHES END_OF_FETCH_COUNT DIRECT_WRITES CONCURRENCY_WAIT_TIME APPLICATION_WAIT_TIME CLUSTER_WAIT_TIME USER_IO_WAIT_TIME PLSQL_EXEC_TIME JAVA_EXEC_TIME CPU_TIME ELAPSED_TIME Copyright 2006 Kyle Hailey #.76 #.77 Wait Types Broken Out 800 waits Latches broken out Ex) Latch: library cache latch Enqueues broken out Ex) Enq: HW - contention Copyright 2006 Kyle Hailey #.78 Waits show Blocking Session V$session. BLOCKING_SESSION -> can build a wait tree: Copyright 2006 Kyle Hailey #.79 Services Services 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. DBMS_SERVICE.CREATE_SERVICE Copyright 2006 Kyle Hailey #.80 Setting up Services dbms_service.CREATE_SERVICE('ora10a',‘A'); dbms_service.START_SERVICE ('ora10a'); -- dbms_service.STOP_SERVICE ('ora10a'); -- dbms_service.DELETE_SERVICE('ora10a'); ORA10a = tnsnames.ora (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) Sqlplus (HOST = kylehpd)(PORT = 1521)) ) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = A) ) ) un/pw@ora10a lsnrctl services Service "A" has 1 instance(s). Instance "v10g", status READY, has 1 handler(s) for this service... Handler(s): "DEDICATED" established:0 refused:0 state:ready Copyright 2006 Kyle Hailey Services in OEM Enable Trace By Service View doesn’t work Copyright 2006 Kyle Hailey #.81 Client Id #.82 Setting 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 Copyright 2006 Kyle Hailey Session Dedicated Scott John Sue Randy Mike Oracle Sessions S1 S2 S3 S4 S4 Oracle Database Host Copyright 2006 Kyle Hailey S5 Mary Tim S6 #.83 Session Dedicated trace Scott John Sue Randy Mike Mary Tim SQL_TRACE=TRUE Oracle Sessions S1 S2 S3 S4 S4 Oracle Database Host Copyright 2006 Kyle Hailey S5 S6 #.84 #.85 Session Pooling trace Scott John Sue Randy Mike Mary Tim APP Server 1 S1, sql_trace=true Oracle Sessions S1 S2 S3 S4 S4 Oracle Database Host Copyright 2006 Kyle Hailey S5 S6 S7 Session Pooling Scott John Sue Randy Mike Set client_id = SCOTT #.86 Mary Tim dbms_monitor.client_id_trace_enable TRUE, FALSE); waits, binds APP (client_id, Server 1 Oracle Sessions S1 S2 S3 S4 S4 Oracle Database Host Copyright 2006 Kyle Hailey S5 S6 S7 #.87 DB_FILE_MULTI_BLOCK_READ_COUNT Auto tuned in 10gR2 Recommended to leave unset in init.ora db_file_multiblock_read_count _db_file_exec_read_count _db_file_optimizer_read_count Copyright 2006 Kyle Hailey 55 55 8 #.88 UNDO Retention Auto Tuned Oracle10G records the times of the longest-running queries and the amount of undo generated to automatically tune the UNDO_RETENTION parameter. IF Autoextend on then undo retention set slightly longer than the longest running query If autoextend off then depends on free space available Bug 5387030 – undo retention higher than set Copyright 2006 Kyle Hailey