Presentation is loading. Please wait.

Presentation is loading. Please wait.

Performance Tuning in Oracle 10g Feel the Power !

Similar presentations


Presentation on theme: "Performance Tuning in Oracle 10g Feel the Power !"— Presentation transcript:

1 Performance Tuning in Oracle 10g Feel the Power !
Kyle Hailey

2 (Hold on to the seat of your pants … )
New Features Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM Misc Part I Eat your Spinach (Hold on to the seat of your pants … ) Part II Wow – the main course Part III Dessert – this is cool (And that’s not all) 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)".

3 Metrics … a new 10g feature to make our lives easier
Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM Misc Part I Part II Part III

4 Motivation What inspired Metrics? Why should you care ?
Some exceptions logons current opened cursors current

5 Statistics have always been a Pain
Eating your Spinach  How do we find Performance Problems With Statistics Statistics have always been a Pain How do YOU find bottlenecks with statistics? YOU DO THE MATH This is TEDIOUS (and your boss probably doesn’t even appreciate you for it ) Some exceptions logons current opened cursors current

6 SQL> Select value from v$sysstat where name=‘physical reads’;
First Tedious Step SQL> Select value from v$sysstat where name=‘physical reads’; VALUE 1,533,787 Not much help …Why? Let see …

7 This tells you … Nothing
GOOD BAD 1,533,787 30 minutes IO’s 30 minutes time time

8 How do You find the Delta?
Where’s the Beef ?

9 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

10 Current 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) Another Option Write your own Scripts Take time to write, no standards In Summary These options take time … whose time?

11 YOUR TIME

12 Solution ! 10g Metrics Available Immediately at your fingertips … for your enjoyment and relaxation, Introducing Metrics Automated Immediate Always there Time saving (whose time? … YOUR time) 10 minutes and 30 minutes in special cases 10 minutes for File IO 30 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$METRIC V$METRIC_HISTORY Combined view onto the other metric tables V$METRICGROUP V$METRICNAME V$SYSMETRIC V$SESSMETRIC V$FILEMETRIC V$EVENTMETRIC V$WAITCLASSMETRIC V$SVCMETRIC V$SYSMETRIC_HISTORY V$FILEMETRIC_HISTORY V$WAITCLASSMETRIC_HISTORY V$SVCMETRIC_HISTORY V$SYSMETRIC_SUMMARY

13 Metrics dependability at your fingertips
Pre-Set intervals 15 second 60 second 10 minutes 30 minutes Current Value for Deltas Rates per second per transaction Ratios Percentages 10 minutes and 30 minutes in special cases 10 minutes for File IO 30 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$METRIC V$METRIC_HISTORY Combined view onto the other metric tables V$METRICGROUP V$METRICNAME V$SYSMETRIC V$SESSMETRIC V$FILEMETRIC V$EVENTMETRIC V$WAITCLASSMETRIC V$SVCMETRIC V$SYSMETRIC_HISTORY V$FILEMETRIC_HISTORY V$WAITCLASSMETRIC_HISTORY V$SVCMETRIC_HISTORY V$SYSMETRIC_SUMMARY

14 Serious Geek Stuff : Our Metric Family
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$kewrtsqlstat (30 Minutes) “not a metric” cumulates values up to 30 minutes, then snapshots it to dba_hist_sqlstat SQL x$kewrtsqlstat (30 minutes) Session V$sessmetric BEGIN_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 Group ID 2 is a superset of 3 4 is a superset of 5 Event class metrics SQL> 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 Blocked User Session Count num of sessions User Transaction Count (Session) num of transactions CPU Time (Session) centi-seconds Physical Reads (Session) num of reads PGA Memory (Session) num of bytes Hard Parse Count (Session) num of parses Total Parse Count (Session) num of parses Physical Reads Ratio (Sess/Sys) % in % 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) Elapsed Time Per User Call Microseconds per call CPU Time Per User Call Microseconds per call Average File Read Time (Files-Long) centi-secs per read Average File Write Time (Files-Long) centi-secs per Write Physical Reads (Files-Long) counts Physical Writes (Files-Long) counts Physical Block Reads (Files-Long) counts Physical Block Writes (Files-Long) counts 1* select * from v$metricgroup GID NAME INTS M_INT GROUP_ID COUNT(*) 0 Event Metrics 1 Event Class Metrics 2 System Metrics Long Duration 3 System Metrics Short Duration 4 Session Metrics Long Duration 5 Session Metrics Short Duration 6 Service Metrics 7 File Metrics Long Duration Max Interval Ie, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltas

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

16 Now What’s the IO? No Calculations, just a simple select :
SQL> Select VALUE , METRIC_UNIT from v$sysmetric where name=‘Physical Reads’ / (Gives per second and per transaction)

17 Answer at your fingertips
GOOD BAD X 3 IO/sec 513 IO/sec 1,533,787 30 minutes IO’s 30 minutes time time

18 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

19 That was now. What was then?
v$sysstat physical reads Low rate Little IO High rate Lots of IO

20 Solution! Metric History Tables
Last 60 minutes of history, in memory v$sysstat physical reads 60 secs delta 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 Volume Per Transaction Response Time Per 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%

21 Family of Metric History Tables
At your fingertips : Statistics V$SYSMETRIC_HISTORY (60 seconds) (including 3 minutes of 15 second history as a bonus!) File IO V$FILEMETRIC_HISTORY (10 minutes) Waits V$WAITCLASSMETRIC_HISTORY ( 60 seconds) Waits V$WAITCLASSMETRIC_HISTORY ( 60 seconds) (V$SESSION_WAIT_HISTORY 10 events) (V$ACTIVE_SESSION_HISTORY 30minutes, roughly)

22 1 hour of 60 second deltas v$sysstat physical reads delta delta delta
SQL> select BEGIN_TIME,FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY; BEGIN_TI FILE_ID PHYSICAL_READS 04:12: 04:12: 04:02: 04:02: 03:52: 03:52: 03:42: 03:42: 03:32: 03:32: 03:22: 03:22: 03:12: 03:12: delta delta 60 secs

23 That’s not all Folks, as a bonus:
v$sysstat physical reads 3 Minutes 15 second deltas Reduced set of stats, only: 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 3 minutes of 15 second deltas 

24 Both Stored in Same Table v$sysmetric_history
3 minutes of 15 second deltas 60 minutes of 1 minute deltas Check and see if there is overlap Not saved to disk but summary is

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

26 How about a 2 days ago? Statistics Waits File IO SQL
Long Term History, 7 days Statistics DBA_HIST_SYSMETRIC_SUMMARY DBA_HIST_SYSMETRIC_HISTORY (alerts) DBA_HIST_SYSSTAT (cumulative) Waits WAITCLASSMETRIC_HISTORY (alerts) DBA_HIST_SYSTEM_EVENT (cumulative) File IO DBA_HIST_FILEMETRIC_HISTORY (alerts) DBA_HIST_FILESTATXS (cumulative) SQL DBA_HIST_SQLSTAT SQL DBA_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

27 EM Exposing Metrics

28 That was the Introduction to Metrics
We saw Current deltas : Metrics Tables Hour History : Metric History Tables Week of History : DBA_HIST Tables Now lets Look at the Groupings Statistics Waits File I/O

29 Statistics Raw : v$sysstat Current Rates: v$sysmetric 15 & 60 seconds
Session Stats 1 Hour : v$sysmetric_history (in memory) 7 Days : dba_hist_sysmetric_summary (with AWR)

30 v$sysmetric 15 Secs for 3 minutes
Per Sec and Per Transaction 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 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 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 Per Sec User Transaction Per Sec

31 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

32 v$sysmetric 60 Sec rates sec/txn for an hour
Per Second and Transaction Per Sec 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% . User Commits User Rollbacks User Transaction DBWR Checkpoints Background Checkpoints Network Traffic Volume Per Transaction Response Time 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 Volume Per Transaction Response Time Per 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%

33 v$sessmetric: Session Metric
BEGIN_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 History Only a one 15 second Delta V$sessmetric BEGIN_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

34 Stats Family of Tables Statistics Metrics v$sysmetric v$metricgroup
BEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNIT v$metricgroup GROUP_ID NAME INTERVAL_SIZE MAX_INTERVAL v$sysstat STATISTIC# NAME CLASS VALUE HASH v$sysmetric_history BEGIN_TIME END_TIME INTSIZE_CSEC GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNIT v$sessmetric BEGIN_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 v$sessstat STATISTIC# NAME CLASS VALUE HASH v$sysmetric_summary BEGIN_TIME END_TIME INTSIZE_CSEC -> intsize GROUP_ID METRIC_ID METRIC_NAME NUM_INTERVAL MAXVAL MINVAL AVERAGE STANDARD_DEVIATION METRIC_UNIT v$metricname GROUP_ID GROUP_NAME METRIC_ID METRIC_NAME METRIC_UNIT

35 Waits Raw : v$system_event Current Deltas : v$eventmetric (60 seconds)
1 Hour : n/a 7 Days : dba_hist_system_event (cumulative) 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 en.name name, num_sess_waiting nsw, time_waited, wait_count 6 from v$eventmetric em, v$event_name en 9 where wait_count > 0 and en.event# = em.event# 12 / NAME NSW TIME_WAITED WAIT_COUNT pmon timer process startup rdbms ipc message control file sequential read control file parallel write log file parallel write SQL*Net message to client SQL*Net more data to client SQL*Net message from client SQL*Net more data from client queue messages Queue Monitor Wait Queue Monitor Task Wait

36 Desc v$eventmetric SQL> 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

37 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# /

38 v$eventmetric results
NAME WAITERS TIME_WAITED WAIT_COUNT pmon timer process startup rdbms ipc message control file sequential read control file parallel write log file parallel write SQL*Net message to client SQL*Net more data to client SQL*Net message from client SQL*Net more data from client queue messages Queue Monitor Wait Queue Monitor Task Wait

39 Files Raw : v$fileio Current Delta : v$filemetric ( 10 Minutes)
1 Hour : v$filemetric_history ( 1 hour, 7 points) 7 Days : dba_hist_filemetric_history (alerts only) SQL> select BEGIN_TIME,FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY; BEGIN_TI FILE_ID PHYSICAL_READS 04:12: 04:12: 04:02: 04:02: 03:52: 03:52: 03:42: 03:42: 03:32: 03:32: 03:22: 03:22: 03:12: 03:12:

40 V$FILEMETRIC_HISTORY
SQL> select BEGIN_TIME, FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY; BEGIN_TI FILE_ID PHYSICAL_READS 04:12: 04:12: 04:02: 04:02: 03:52: 03:52: ... For the last hour

41 Metrics – in summary Current rates automatically calculated
History of Rates for an hour in memory History kept for a week on disk

42 Metrics Current Values Last Hour Week of History V$METRIC
V$METRIC_HISTORY Combined view onto the other metric tables V$METRICGROUP V$METRICNAME Current Values V$SYSMETRIC V$SESSMETRIC V$FILEMETRIC V$EVENTMETRIC V$WAITCLASSMETRIC V$SVCMETRIC Last Hour V$SYSMETRIC_HISTORY V$FILEMETRIC_HISTORY V$WAITCLASSMETRIC_HISTORY V$SVCMETRIC_HISTORY V$SYSMETRIC_SUMMARY – avg, std dev, max, min Week of History dba_hist_sysmetric_summary dba_hist_system_event (cumulative) dba_hist_filemetric_history (alerts) V$METRIC V$METRIC_HISTORY Combined view onto the other metric tables V$METRICGROUP V$METRICNAME V$SYSMETRIC V$SESSMETRIC V$FILEMETRIC V$EVENTMETRIC V$WAITCLASSMETRIC V$SVCMETRIC V$SYSMETRIC_HISTORY V$FILEMETRIC_HISTORY V$WAITCLASSMETRIC_HISTORY V$SVCMETRIC_HISTORY V$SYSMETRIC_SUMMARY

43 Metrics Family of Tables
Stats ( V$stat_name) Waits ( V$event_name ) Files Raw V$sysstat v$system_event v$event_histogram v$system_wait_class v$fileio Now v$metricgroup v$metricname V$sysmetric v$eventmetric v$waitclassmetric v$filemetric 1 Hour V$sysmetric_history V$sysmetric_summary v$waitclassmetric_history v$filemetric_history 7 days DBA_HIST_* SYSMETRIC_SUMMARY SYSSTAT (cumulative) SYSMETRIC_HISTORY (alerts) SYSTEM_EVENT(cumulative) WAITCLASSMETRIC_HISTORY (alert) FILESTATXS (cumulative) TEMPSTATXS (cumulative) FILEMETRIC_HISTORY (alert)

44 Wait Classes Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ )
ADDM Misc Part I Part II Part III

45 Wait Classes Configuration (20) Administrative (39) Application (11)
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) 800 waits in 10g Latchs and locks have been broken out into their own waits Ie latch: redo copy enqueue: CI SQL> select * from v$system_wait_class; WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED Other Application Configuration Administrative Concurrency Commit Idle Network User I/O System I/O

46 Wait Classes in EM

47 v$waitclassmetric_history
Wait Class Tables v$system_wait_class cumulative v$waitclassmetric Current rates v$waitclassmetric_history Hour of rates (60 second intervals) SQL> column name format a20 SQL> select en.wait_class name, average_waiter_count awc, dbtime_in_wait dbt, time_waited, wait_count 7 from v$waitclassmetric wcm, ( select distinct wait_class#, wait_class from v$event_name) en 10 where wcm.wait_class# = en.wait_class# 12 / NAME AWC DBT TIME_WAITED WAIT_COUNT Other Application Configuration Administrative Concurrency Commit Idle Network User I/O System I/O Scheduler Cluster

48 Waits Metrics Wait Classes Wait Events Cumulative Current deltas
Last Hour Last 7 days Wait Classes v$system_wait_class WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS TOTAL_WAITS TIME_WAITED v$waitclassmetric BEGIN_TIME END_TIME INTSIZE_CSEC WAIT_CLASS_ID WAIT_CLASS# NUM_SESS_WAITING TIME_WAITED WAIT_COUNT v$waitclassmetric_history BEGIN_TIME END_TIME INTSIZE_CSEC WAIT_CLASS_ID WAIT_CLASS# NUM_SESS_WAITING TIME_WAITED WAIT_COUNT dba_hist_ waitclassmetric_history Only gets populated with alerts v$event_name EVENT# EVENT_ID NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS Wait Events V$WAITCLASSMETRIC, V$WAITCLASSMETRIC_HISTORY CLASS_ID -> WAIT_CLASS_ID Add WAIT_CLASS# column v$eventmetric BEGIN_TIME END_TIME INTSIZE_CSEC EVENT_ID NUM_SESS_WAITING TIME_WAITED WAIT_COUNT No in memory history v$system_event EVENT TOTAL_WAITS TOTAL_TIMEOUTS TIME_WAITED AVERAGE_WAIT TIME_WAITED_MICRO EVENT_ID dba_hist_system_event (Cumulative)

49 Time Model Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM
Misc Part I Part II 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. Part III

50 Time Model New concept DB Time Total time for all database calls
cpu time wait time Session Time Model SQL> select STAT_NAME, value from V$SESS_TIME_MODEL where sid=1; DB time DB CPU background cpu time sequence load elapsed time parse time elapsed hard parse elapsed time sql execute elapsed time global cache cr block receive time global cache current block receive time global cache get time connection management call elapsed time failed parse elapsed time hard parse (sharing criteria) elapsed time hard parse (bind mismatch) elapsed time PL/SQL execution elapsed time inbound PL/SQL rpc elapsed time PL/SQL compilation elapsed time Java execution elapsed time bind/define call elapsed time cluster wait time concurrency wait time application wait time user I/O wait time System time model SQL> select STAT_NAME, value from V$SYS_TIME_MODEL; DB time E+10 DB CPU E+10 background cpu time E+10 sequence load elapsed time parse time elapsed hard parse elapsed time sql execute elapsed time E+10 connection management call elapsed time failed parse elapsed time hard parse (sharing criteria) elapsed time hard parse (bind mismatch) elapsed time PL/SQL execution elapsed time PL/SQL compilation elapsed time

51 Time Model areas Total Time CPU Elapsed Time SQL execution
Plsql execution (sql execute subtracted out) Java execution Connection time

52 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

53 Total Time Total Database Time

54 Total and CPU =~ DB Wait Time DB CPU Time

55 Total and CPU and Parse Time
DB Wait Time DB CPU Time Parse Elapsed Time

56 Parse Time Parse Elapsed Time

57 hard parse elapsed time

58 Hard Parse Sharing Criteria
hard parse (sharing criteria) elapsed time Parse time elapsed hard parse elapsed time

59 Hard Parse Bind Mismatch
hard parse (bind mismatch) elapsed time hard parse (sharing criteria) 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 Parse time elapsed hard parse elapsed time

60 Time Model Tables Current cumulative values V$SYS_TIME_MODEL
V$SESS_TIME_MODEL AWR Snapshots of cumulative values DBA_HIST_SYS_TIME_MODEL

61 ASH Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM Misc
Part I Part II 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 Part III

62 ASH A Revolution in Monitoring
Active Session History New 10g Every Second it collects data 1 hour of history in Memory for immediate access at your fingertips This hour of data could change your life 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 */ ---

63 It’s a Revolution and it’s an Evolution
Oracle 6 … ie the dark ages … there was Cache Buffer Hit Ratio Oracle 7 … turned the lights on … Wait Events … hallelujah I can see the light Oracle 10g … ASH has landed

64 ASH – Intelligence for the new Millennium
Selectively Collects Data More active, more data collected Less active, less data collected It self adjusts for your needs Old methods collect everything Costly Limits fine Granularity

65 ASH – In Memory Collects active session data only
History v$session_wait + v$session + extras Circular Buffer - 1M to 128M (~2% of SGA) Flushed every hour to disk or when buffer 2/3 full 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 */ ---

66 ASH Sizing … Bigger isn’t always Better
Avg row around 150bytes 3600 secs in an hour ~ ½ Meg per Active Session per hour That’s generally over an hour of ASH

67 v$active_session_history
SAMPLE_ID NUMBER SAMPLE_TIME TIMESTAMP(3) When Session 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) State SESSION_STATE VARCHAR2(7) WAIT_TIME NUMBER Wait EVENT VARCHAR2(64) EVENT_ID NUMBER EVENT# NUMBER SEQ# NUMBER P NUMBER P NUMBER P NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER CURRENT_OBJ# NUMBER CURRENT_FILE# NUMBER CURRENT_BLOCK# NUMBER0 SQL SQL_ID VARCHAR2(13) SQL_CHILD_NUMBER NUMBER SQL_PLAN_HASH_VALUE NUMBER SQL_OPCODE NUMBER QC_SESSION_ID NUMBER QC_INSTANCE_ID NUMBER Duration TIME_WAITED NUMBER

68 X Consumers CPU Waits Event I/O File Block Time Top Session Top User
Top SQL Top Object Top Module.Action Top Program Top Service Top Client Top Wait CPU Waits Event I/O File Block Time X

69 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_id order by count(*) desc;

70 Results Top CPU Session
SESSION_ID COUNT(*) Select session_id, session_serial# , count(*) , round((count(*)*100)/(5*60),0) "%", lpad('*',round((count(*)*10)/(5*60),0),'*') "Bar" from v$active_session_history where session_state= 'ON CPU' and SAMPLE_TIME > sysdate - (5/(24*60)) group by session_id, session_serial# order by count(*) desc /

71 ASH in OEM 10g

72 v$active_session_history
Family of ASH Tables v$session_wait v$active_session_history V$session_wait_history wrh$active_session_history

73 v$active_session_history
ASH Tables current 7 days (disk) 10 samples hour 1 in 10 v$session_wait SID SEQ# EVENT P1TEXT P1 P1RAW P2TEXT P2 P2RAW P3TEXT P3 P3RAW WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS WAIT_TIME SECONDS_IN_WAIT STATE v$session_wait_history SID SEQ# EVENT# EVENT P1TEXT P1 P2TEXT P2 P3TEXT P3 WAIT_TIME v$active_session_history SAMPLE_ID SAMPLE_TIME SESSION_ID SESSION_SERIAL# USER_ID SQL_ID SQL_CHILD_NUMBER SQL_PLAN_HASH_VALUE SQL_OPCODE SERVICE_HASH SESSION_TYPE SESSION_STATE QC_SESSION_ID QC_INSTANCE_ID SEQ# EVENT# P1 P2 P3 WAIT_TIME TIME_WAITED CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# PROGRAM MODULE ACTION CLIENT_ID wrh$active_session_history SNAP_D DBID INSTANCE_NUMBER SAMPLE_ID SAMPLE_TIME SESSION_ID SESSION_SERIAL# USER_ID SQL_ID SQL_CHILD_NUMBER SQL_PLAN_HASH_VALUE SQL_OPCODE SERVICE_HASH SESSION_TYPE SESSION_STATE QC_SESSION_ID QC_INSTANCE_ID SEQ# EVENT_ID P1 P2 P3 WAIT_TIME TIME_WAITED CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# PROGRAM MODULE ACTION CLIENT_ID v$event_name EVENT_ID EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_CLASS_ID WAIT_CLASS# WAIT_CLASS

74 AWR Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM Misc
Part I Part II Part III

75 Automatic Workload Repository
Statspack on Steroids More efficient than Statspack Keeps stats every hour Stores by default the last 7 days Not doing multiple scans on v$sql Not capturing as much data from v$sql Statspack was based on thresholds AWR is based on work done in the last interval

76 Snapshoting BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END; /

77 New in 10g DBA_HIST 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_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 DBA_HIST_RESOURCE_LIMIT DBA_HIST_SHARED_POOL_ADVICE ?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 -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 - ? New in 10g

78 ADDM Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ ) ADDM Misc
Part I Part II Part III

79 Automatic Database Diagnostic Monitor
Every Hour with AWR Analyze Identify problems Proposes solutions

80 ADDM Page

81 ADDM Details

82 ADDM Advice

83 ADDM tables dba_advisor_findings TASK_NAME, TASK_ID (is indexed)
dba_advisor_recommendations  TASK_ID,FINDING_ID dba_advisor_actions          TASK_ID and REC_ID dba_advisor_rationale        TASK_ID and REC_ID dba_advisor_objects  TASK_ID , OBJECT_ID from actions or rationale.

84 ADDM tables Add Free lists or move to ASSM Actions BBW:
Read & write contention on a block Segment Tuning Findings objects Tables Recommendations Rational SQL objects Recos 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.

85 Advisory Framework tables
Could be just a message w/o command or rational Like investigate application logic Types: Application Analysis DB Configuration Host Configuration SQL Tuning Segment Tuning Schema Types: PROBLEM SYMPTOM INFORMATION Actions Findings Recommendations Rational Doesn’t use type ADDM does not use this connection (maybe SQL Tuning Advisor ) 22 types of which ADDM uses 7: SQL DATABASE OBJECT (Tables, Indexes, ...) TABLESPACE DATABASE BLOCK DATABASE FILE DATABASE LATCH DATABASE ENQ objects

86 ADDM tables dba_advisor_actions OWNER TASK_ID TASK_NAME REC_ID
ACTION_ID OBJECT_ID COMMAND COMMAND_ID FLAGS ATTR1 ATTR2 ATTR3 ATTR4 ATTR5 ATTR6 NUM_ATTR1 NUM_ATTR2 NUM_ATTR3 NUM_ATTR4 NUM_ATTR5 MESSAGE dba_advisor_findings OWNER TASK_ID TASK_NAME FINDING_ID TYPE PARENT OBJECT_ID IMPACT_TYPE IMPACT MESSAGE MORE_INFO dba_advisor_recommendations OWNER REC_ID TASK_ID TASK_NAME FINDING_ID TYPE RANK PARENT_REC_IDS BENEFIT_TYPE BENEFIT ANNOTATION_STATUS dba_advisor_rationale OWNER TASK_ID TASK_NAME REC_ID RATIONALE_ID IMPACT_TYPE IMPACT MESSAGE OBJECT_ID TYPE ATTR1 ATTR2 ATTR3 ATTR4 ATTR5 dba_advisor_objects OWNER OBJECT_ID TYPE TYPE_ID TASK_ID TASK_NAME ATTR1 ATTR2 ATTR3 ATTR4

87 Miscellaneous Metrics Wait Classes Time Model ASH AWR ( DBA_HIST_ )
ADDM Misc Part I Part II Part III

88 Miscellaneous Field naming conventions Wait Improvements Services
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

89 Fields Names Names Ids Name Hash Event Statistic Waitclass Event#
Event_id Statistic_id Waitclass_id

90 Wait Histograms V$event_histogram 1ms to 1 hour buckets 23 buckets
< 1 ms, < 2 ms, < 4 ms, < 8 ms, ..., < 2^22 ms 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 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 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                            7        588 SQL*Net message from client                            5        588 SQL*Net message from client                            2        588 SQL*Net message from client                           3        588 SQL*Net message from client                           3        588 SQL*Net message from client                           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           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.

91 Waits in v$session and v$sql
V$session exposes all the fields from v$session_wait SEQ# NUMBER EVENT# NUMBER EVENT VARCHAR2(64) P1TEXT VARCHAR2(64) P NUMBER P1RAW RAW(4) P2TEXT VARCHAR2(64) P NUMBER P2RAW RAW(4) P3TEXT VARCHAR2(64) P 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) 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');

92 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

93 Wait Types Broken Out 800 waits Latches broken out Enqueues broken out
Ex) Latch: library cache latch Enqueues broken out Ex) Enq: HW - contention

94 Waits show Blocking Session
V$session. BLOCKING_SESSION -> can build a wait tree:

95 Waits History of last 10 waits
select sid, event, p1,p2,p3 from v$session_wait_history SID EVENT P P P3 36 db file sequential read 36 SQL*Net message from client 36 SQL*Net message to client 36 db file sequential read 36 db file sequential read 36 db file sequential read 36 db file sequential read 36 db file sequential read 36 db file sequential read

96 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.

97 Client Id 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 Script to Extract Client Trace trcsess

98 Session Dedicated S1 S2 S3 S4 S4 S5 S6 Scott John Sue Mike Randy Tim
Mary Oracle Sessions S1 S2 S3 S4 S4 S5 S6 Oracle Database Host

99 Session Dedicated trace
Scott John Sue Mike Randy Tim Mary SQL_TRACE=TRUE Oracle Sessions S1 S2 S3 S4 S4 S5 S6 Oracle Database Host

100 Session Pooling trace S1 S2 S3 S4 S4 S5 S6 S7 Scott John Sue Mike
Randy Tim Mary APP Server 1 S1, sql_trace=true Oracle Sessions S1 S2 S3 S4 S4 S5 S6 S7 Oracle Database Host

101 Session Pooling S1 S2 S3 S4 S4 S5 S6 S7 Scott John Sue Mike Randy Tim
Mary Set client_id = SCOTT APP Server 1 dbms_monitor.client_id_trace_enable (client_id, TRUE, FALSE); waits, binds Oracle Sessions S1 S2 S3 S4 S4 S5 S6 S7 Oracle Database Host

102 ------ Reference -------------

103 System Statistics View
Stats ( V$stat_name) Waits ( V$event_name ) Time Model sql Raw V$sysstat v$system_event v$event_histogram v$system_wait_class v$sys_time_model V$sql Now V$sysmetric v$eventmetric v$waitclassmetric Some goes into sysmetric ASH x$kewrtsqlstat 1 Hour V$sysmetric_history V$sysmetric_summary v$waitclassmetric_history 7 days DBA_HIST_* SYSMETRIC_SUMMARY SYSSTAT (cumulative) SYSMETRIC_HISTORY (alerts) SYSTEM_EVENT WAITCLASSMETRIC_HISTORY (alert) SYS_TIME_MODEL SQLSTAT

104 Session Statistics View
stats waits waitclasses Time Model sql V$ V$sessstat V$session_event V$sess_time_model * (some stats possible from ASH) Metrics V$sessmetric history AWR WRH$_SESSMETRIC_HISTORY * (alert only)

105 V$metric v$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

106 Metric Group and v$metric
2 is a superset of 3 4 is a superset of 5 1* select * from v$metricgroup GID NAME INTS M_INT GROUP_ID COUNT(*) 0 Event Metrics (per event) 1 Event Class Metrics (per waitclass) 2 System Metrics Long Duration 3 System Metrics Short Duration 4 Session Metrics Long Duration (blcoked user) 5 Session Metrics Short Duration (per session) 6 Service Metrics (per service) 7 File Metrics Long Duration (per file) Group ID 2 is a superset of 3 4 is a superset of 5 Event class metrics SQL> 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 Blocked User Session Count num of sessions User Transaction Count (Session) num of transactions CPU Time (Session) centi-seconds Physical Reads (Session) num of reads PGA Memory (Session) num of bytes Hard Parse Count (Session) num of parses Total Parse Count (Session) num of parses Physical Reads Ratio (Sess/Sys) % in % 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) Elapsed Time Per User Call Microseconds per call CPU Time Per User Call Microseconds per call Average File Read Time (Files-Long) centi-secs per read Average File Write Time (Files-Long) centi-secs per Write Physical Reads (Files-Long) counts Physical Writes (Files-Long) counts Physical Block Reads (Files-Long) counts Physical Block Writes (Files-Long) counts 1* select * from v$metricgroup GID NAME INTS M_INT GROUP_ID COUNT(*) 0 Event Metrics 1 Event Class Metrics 2 System Metrics Long Duration 3 System Metrics Short Duration 4 Session Metrics Long Duration 5 Session Metrics Short Duration 6 Service Metrics 7 File Metrics Long Duration Max Interval Ie, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltas Ie, v$sysmetric_history keeps the last hour for long duration deltas, 60s, and the last 3 minutes for short duration, 15 second deltas Max Interval

107 ASH ASH provides two x$ fixed tables
x$kewash - returns a row for every ASH sample taken x$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_tim e, 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,'FORE GROUND', 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.progra m, 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

108 X$ Desc x$ash desc x$ash SQL> desc x$kewash 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 P NUMBER P NUMBER P NUMBER WAIT_TIME NUMBER TIME_WAITED NUMBER PROGRAM VARCHAR2(48) MODULE VARCHAR2(48) ACTION VARCHAR2(32) CLIENT_ID VARCHAR2(64) SQL> 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

109 Sql metrics: x$kewrtsqlstat

110 ASH init.ora Statistics_level=typical _active_session_history=true

111 INIT.ORA 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: 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:

112 EM Product Layout for Performance
Database Home Page Database Performance Page Drilldowns SQL Session

113 EM Pages Layout Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

114 Buffer Busy Waits Use Case

115 Three Paths Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

116 ADDM Path Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

117 Database Home Page

118 ADDM Home Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

119 ADDM Home

120 ADDM Details Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

121 ADDM Details

122 Manual Path Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

123 Database Home Page

124 Database Home Page

125 Database Home Page

126 Performance Page Home Page Perf Page Top Session Top SQL Wait Detail
SQL Detail Session Detail ADDM ADDM Details

127 Database Performance Page

128 Database Performance Page highlight

129 Wait Drill Down Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

130 Wait Drill Down

131 Wait Drill Down

132 Wait Drill Down

133 Wait Drill Down highlight

134 Wait Drill Down – Top SQL

135 SQL Details Home Page Perf Page Top Session Wait Detail Top SQL
Session Detail ADDM ADDM Details

136 SQL Details

137 Combined Home Page Perf Page Top Session Wait Detail Top SQL
SQL Detail Session Detail ADDM ADDM Details

138 Comparison


Download ppt "Performance Tuning in Oracle 10g Feel the Power !"

Similar presentations


Ads by Google