• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Oracle 10g Performance: chapter 04 new features
 

Oracle 10g Performance: chapter 04 new features

on

  • 484 views

 

Statistics

Views

Total Views
484
Views on SlideShare
484
Embed Views
0

Actions

Likes
0
Downloads
55
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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)" .
  • /* DBA_THRESHOLDS METRICS_NAME WARNING_OPERATOR WARNING_VALUE CRITICAL_OPERATOR CRITICAL_VALUE OBSERVATION_PERIOD CONSECUTIVE_OCCURRENCES INSTANCE_NAME OBJECT_TYPE OBJECT_NAME STATUS */ col op for a4 col warn for a6 col alert for a35 col obj for a15 select metrics_name alert, warning_operator op, warning_value warn , object_name obj from dba_thresholds /
  • var SERV varchar2(20); exec :SERV := 'db3'; begin DBMS_SERVER_ALERT.SET_THRESHOLD( METRICS_ID => DBMS_SERVER_ALERT.CPU_TIME_PER_CALL, WARNING_OPERATOR => DBMS_SERVER_ALERT.OPERATOR_GE, WARNING_VALUE => '8000', CRITICAL_OPERATOR => DBMS_SERVER_ALERT.OPERATOR_GE, CRITICAL_VALUE => '10000', OBSERVATION_PERIOD => 1, CONSECUTIVE_OCCURRENCES => 2, INSTANCE_NAME => :serv, OBJECT_TYPE => DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE, OBJECT_NAME => :serv ) ; end; / set serveroutput on DECLARE vWarnOp NUMBER(10); vWarnVal VARCHAR2(100); vCritOp NUMBER(10); vCritVal VARCHAR2(100); vObsvPer NUMBER(5); vConOcur NUMBER(5); BEGIN dbms_server_alert.get_threshold( METRICS_ID => DBMS_SERVER_ALERT.CPU_TIME_PER_CALL, WARNING_OPERATOR => vWarnOp, WARNING_VALUE => vWarnVal, CRITICAL_OPERATOR => vCritOp, CRITICAL_VALUE => vCritVal, OBSERVATION_PERIOD => vObsvPer, CONSECUTIVE_OCCURRENCES => vConOcur, INSTANCE_NAME => :serv, OBJECT_TYPE => DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE, OBJECT_NAME => :serv ) ; dbms_output.put_line('WarnOp: ' || TO_CHAR(vWarnOp)); dbms_output.put_line('WarnVal: ' || vWarnVal); dbms_output.put_line('CritOp: ' || TO_CHAR(vCritOp)); dbms_output.put_line('CritVal: ' || vCritVal); dbms_output.put_line('Observation: ' || vObsvper); dbms_output.put_line('Occurences: ' || vConOcur); END; /
  • Some exceptions logons current opened cursors current
  • 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
  • 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 -------- --------- ---------------------------------------- -------------------- 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 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
  • 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
  • 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%
  • 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
  • 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%
  • Waits V$WAITCLASSMETRIC_HISTORY ( 60 seconds) (V$SESSION_WAIT_HISTORY 10 events) (V$ACTIVE_SESSION_HISTORY 30minutes, roughly)
  • 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
  • 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 FUNCTION ASH_REPORT_HTML / ASH_REPORT_TEXT FUNCTION AWR_REPORT_HTML / AWR_REPORT_TEXT FUNCTION AWR_DIFF_REPORT_HTML / AWR_DIFF_REPORT_TEXT FUNCTION AWR_SQL_REPORT_HTML / AWR_SQL_REPORT_TEXT PROCEDURE CREATE_SNAPSHOT PROCEDURE CREATE_BASELINE PROCEDURE DROP_BASELINE PROCEDURE DROP_SNAPSHOT_RANGE PROCEDURE MODIFY_SNAPSHOT_SETTINGS
  • SQL> desc DBA_HIST_SEG_STAT Name ------------------------------- SNAP_ID DBID INSTANCE_NUMBER TS# OBJ# DATAOBJ# LOGICAL_READS_TOTAL LOGICAL_READS_DELTA BUFFER_BUSY_WAITS_TOTAL BUFFER_BUSY_WAITS_DELTA DB_BLOCK_CHANGES_TOTAL DB_BLOCK_CHANGES_DELTA PHYSICAL_READS_TOTAL PHYSICAL_READS_DELTA PHYSICAL_WRITES_TOTAL PHYSICAL_WRITES_DELTA PHYSICAL_READS_DIRECT_TOTAL PHYSICAL_READS_DIRECT_DELTA PHYSICAL_WRITES_DIRECT_TOTAL PHYSICAL_WRITES_DIRECT_DELTA ITL_WAITS_TOTAL ITL_WAITS_DELTA ROW_LOCK_WAITS_TOTAL ROW_LOCK_WAITS_DELTA GC_CR_BLOCKS_SERVED_TOTAL GC_CR_BLOCKS_SERVED_DELTA GC_CU_BLOCKS_SERVED_TOTAL GC_CU_BLOCKS_SERVED_DELTA GC_BUFFER_BUSY_TOTAL GC_BUFFER_BUSY_DELTA GC_CR_BLOCKS_RECEIVED_TOTAL GC_CR_BLOCKS_RECEIVED_DELTA GC_CU_BLOCKS_RECEIVED_TOTAL GC_CU_BLOCKS_RECEIVED_DELTA SPACE_USED_TOTAL SPACE_USED_DELTA SPACE_ALLOCATED_TOTAL SPACE_ALLOCATED_DELTA TABLE_SCANS_TOTAL
  • column avg_ms for 999,999.999
  • Session Time Model SQL> select STAT_NAME, value from V$SESS_TIME_MODEL where sid=1; DB time 143 DB CPU 290000 background cpu time 0 sequence load elapsed time 0 parse time elapsed 0 hard parse elapsed time 0 sql execute elapsed time 0 global cache cr block receive time 0 global cache current block receive time 0 global cache get time 0 connection management call elapsed time 0 failed parse elapsed time 0 hard parse (sharing criteria) elapsed time 0 hard parse (bind mismatch) elapsed time 0 PL/SQL execution elapsed time 0 inbound PL/SQL rpc elapsed time 0 PL/SQL compilation elapsed time 0 Java execution elapsed time 0 bind/define call elapsed time 0 cluster wait time 0 concurrency wait time 0 application wait time 0 user I/O wait time 0 System time model SQL> select STAT_NAME, value from V$SYS_TIME_MODEL; DB time 3.9837E+10 DB CPU 2.4055E+10 background cpu time 2.1808E+10 sequence load elapsed time 15939410 parse time elapsed 451760577 hard parse elapsed time 178851736 sql execute elapsed time 3.6900E+10 connection management call elapsed time 1045589383 failed parse elapsed time 848439 hard parse (sharing criteria) elapsed time 3347865 hard parse (bind mismatch) elapsed time 1515268 PL/SQL execution elapsed time 418089534 inbound PL/SQL rpc elapsed time 0 PL/SQL compilation elapsed time 37666077 Java execution elapsed time 0 bind/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
  • 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 ------------- ----------- -------------------- ----------- ----------- 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 a20 SQL> 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 1 Application 0 0 0 7 Configuration 0 0 1 2 Administrative 0 0 0 0 Concurrency 0 0 0 0 Commit 0 0 1 2 Idle 17 0 104965 278 Network 0 0 0 50 User I/O 0 3 10 614 System I/O 0 10 33 81 Scheduler 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
  • 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');
  • trcsess [output=] [session=] [clientid=] [service=] [action=] [module=]
  • From Tim Gorman MBRC used rather than db_file_multiblock_read_count If db_file_multiblock_read_count > MBRC used to derive _db_file_ optimizer_ read_count If db_file_multiblock_read_count <= MBRC _db_file_ optimizer _read_count is default If no workload stats db_file_multiblock_read_count used to set _db_file_ optimizer_ read_count and affects optimizer decision db_file_multiblock_read_count 55 _db_file_exec_read_count 55 _db_file_optimizer_read_count 8
  • Bug 5387030 - Automatic tuning of undo_retention causes unusual extra space allocation Doc ID: Note:5387030.8

Oracle 10g Performance: chapter 04 new features Oracle 10g Performance: chapter 04 new features Presentation Transcript

  • 10g New Performance Features 1. Alerts 2. Metrics 3. AWR ( 7 days of history DBA_HIST_ ) 4. Time Model 5. Wait Classes 6. Misc Copyright 2006 Kyle Hailey #.1
  • Alerts Set select metrics_name alert, In 10g, alerts are warning_operator op, managed in the warning_value warn , database object_name obj from dba_thresholds; ALERT OP WARN ----------------------------------- ---- ------ OBJ ------- Average Users Waiting Counts GT 10 Concurrency Blocked User Session Count GT 0 CPU Time Per User Call GE 8000 db3 Logons Per Sec GE 100 Session Limit % GT 90 Tablespace Space Usage GE 85 Tablespace Space Usage GE 90 SYSTEM Copyright 2006 Kyle Hailey #.2
  • Alerts Outstandingselect reason, object_type type, object_name namefrom dba_outstanding_alerts; REASON TYPE NAME ------------------------------------------ ----------- ------- Tablespace [PERFSTAT] is [97 percent] full TABLESPACE PERFSTA Copyright 2006 Kyle Hailey #.3
  • Alerts SettingDBMS_SERVER_ALERT.SET_THRESHOLD( METRICS_ID => DBMS_SERVER_ALERT.CPU_TIME_PER_CALL, WARNING_OPERATOR => DBMS_SERVER_ALERT.OPERATOR_GE,dbms_server_alert.set_threshold( WARNING_VALUE METRICS_ID => 8000, => dbms_server_alert.tablespace_pct_full, CRITICAL_OPERATOR WARNING_OPERATOR => DBMS_SERVER_ALERT.OPERATOR_GE, => dbms_server_alert.operator_ge, CRITICAL_VALUE WARNING_VALUE => 10000, => 90, OBSERVATION_PERIOD CRITICAL_OPERATOR => 1, => dbms_server_alert.operator_ge, CONSECUTIVE_OCCURRENCES => 2, CRITICAL_VALUE => 99, INSTANCE_NAME OBSERVATION_PERIOD => SID, => 1, OBJECT_TYPE CONSECUTIVE_OCCURRENCES => DBMS_SERVER_ALERT.OBJECT_TYPE_SERVICE, => 1, OBJECT_NAME INSTANCE_NAME => SID) => null, OBJECT_TYPE => dbms_server_alert.object_type_tablespace, OBJECT_NAME => SYSTEM); http://www.psoug.org/reference/dbms_serv_alert.html Copyright 2006 Kyle Hailey #.4
  • 9i10g Metrics DBA_HIST_SQLSTAT v$sql v$sql SQL Waits v$system_event v$system_event V$eventmetric V$waitclassmetric V$session_wait Metrics V$session_event V$sesstat v$sysstat v$systat Stats v$session v$session Sessions V$sessmetric V$sysmetric Copyright 2006 Kyle Hailey #.5
  • Metrics What inspired Metrics?  Alerting But … metrics make our lives easier  Old statistics were cumulative  Old statistics lacked historyQuestion: 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 minutesIO’s 30 minutes time time Copyright 2006 Kyle Hailey #.8
  • 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 #.9
  • 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) Overkill to run statspack for one or two statistics, now 10g gives us metric tables Copyright 2006 Kyle Hailey #.10
  • Performance Metric Deltas Kinds of Metric Tables1. Metric – current2. Metric History – last hour Current Deltas History of Values over last hourV$EVENTMETRIC V$FILEMETRIC_HISTORYV$FILEMETRIC V$SYSMETRIC_HISTORYV$SESSMETRIC V$SERVICEMETRIC_HISTORYV$SERVICEMETRIC V$WAITCLASSMETRIC_HISTORYV$SYSMETRICV$SYSMETRIC_SUMMARYV$WAITCLASSMETRIC #.11 Copyright 2006 Kyle Hailey
  • Metrics  Intervals  Calculations  15 second  Deltas  60 second  Rates  10 minutes - file IO  per second  30 minutes - sql  per transaction  Ratios  Percentages 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  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 minutesIO’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$sysmetricdesc v$sysmetric BEGIN_TIME END_TIME INTSIZE_CSEC – interval value in 1/100sec GROUP_ID METRIC_ID METRIC_NAME VALUE METRIC_UNITAttention: metric_names are different from v$sysstat Copyright 2006 Kyle Hailey #.16
  • v$sysmetric 15 Secs Per Sec and Per Transaction Physical ReadsBuffer Cache Hit Ratio Physical WritesMemory Sorts Ratio Physical Reads DirectExecute Without Parse Ratio Redo Generated LogonsSoft Parse Ratio User CallsDatabase CPU Time Ratio Logical ReadsLibrary Cache Hit Ratio Redo WritesShared Pool Free % Total Table Scans Full Index ScansTxns Per Logon DB Block Gets Consistent Read Gets Per Sec DB Block Changes Consistent Read Changes User Transaction Per Sec Executions Copyright 2006 Kyle Hailey #.17
  • v$sysmetric 60 SecBuffer Cache Hit Ratio Current Logons CountMemory Sorts Ratio Current Open Cursors CountRedo Allocation Hit Ratio User Limit %User Commits Percentage SQL Service Response TimeUser Rollbacks Percentage Database Wait Time RatioCursor Cache Hit Ratio Database CPU Time RatioRows Per Sort Row Cache Hit RatioExecute Without Parse Ratio Row Cache Miss RatioSoft Parse Ratio Library Cache Hit RatioUser Calls Ratio Library Cache Miss RatioGlobal Cache Average CR Get Time Shared Pool Free %Global Cache Average Current Get Time PGA Cache Hit %Global Cache Blocks Corrupted Process Limit %Global Cache Blocks Lost Session Limit % Txns Per Logon Copyright 2006 Kyle Hailey #.18
  • v$sysmetric 60 Sec Per Second and TransactionPer Sec Physical Reads Disk Sort Physical Writes Enqueue Timeouts User Commits Physical Reads Direct Enqueue Waits User Rollbacks Physical Writes Direct Enqueue Deadlocks User Transaction Physical Reads Direct Lobs Enqueue Requests Physical Writes Direct Lobs DB Block Gets DBWR Checkpoints Redo Generated Consistent Read Gets Background Checkpoints Logons DB Block Changes Network Traffic Volume Open Cursors Consistent Read Changes User Calls CPU UsagePer Transaction Recursive Calls CR Blocks Created Logical Reads CR Undo Records AppliedResponse Time Redo Writes User Rollback Undo Records Long Table Scans Applied Total Table Scans Leaf Node Splits Full Index Scans Branch Node Splits Total Index Scans PX downgraded 1 to 25% Total Parse Count PX downgraded 25 to 50% Hard Parse Count PX downgraded 50 to 75% Parse Failure Count PX downgraded 75 to 99% . Copyright 2006 Kyle Hailey #.19
  • v$sessmetricdesc v$sessmetric BEGIN_TIME • Only 15 second END_TIME 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 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 Copyright 2006 Kyle Hailey #.21
  • 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? Copyright 2006 Kyle Hailey #.22
  • 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 60 secs Copyright 2006 Kyle Hailey #.23
  • Metric History TablesLast hour of statistics at your fingertips :Statistics 3 minutes of 15 second  V$SYSMETRIC_HISTORY deltas  60 seconds for an hour  3 minutes of 15 second File IO 60 minutes of 1 minute deltas  V$FILEMETRIC_HISTORY  10 minutes for an hour Waits  V$WAITCLASSMETRIC_HISTORY  60 seconds for an hour Copyright 2006 Kyle Hailey #.24
  • What was IO 30 minutes ago?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)))order by end_time; TO_CHAR(END_TIM VALUE METRIC_UNIT 08-JAN-08 11:38 118.65 Reads Per Second 08-JAN-08 11:39 76.6166667 Reads Per Second 08-JAN-08 11:40 3.44770153 Reads Per Second 08-JAN-08 11:41 28.7 Reads Per Second 08-JAN-08 11:42 19.6166667 Reads Per Second Copyright 2006 Kyle Hailey #.25
  • V$FILEMETRIC_HISTORYselect BEGIN_TIME, FILE_ID, PHYSICAL_READS from V$FILEMETRIC_HISTORY; BEGIN_TI FILE_ID PHYSICAL_READS 04:12:16 1 208 04:12:16 2 600 Physical Reads 04:02:18 1 600 04:02:18 2 189 Broken down by 03:52:15 1 1922 file 03:52:15 2 2082 … Copyright 2006 Kyle Hailey #.26
  • Metric Alerts If Alerts fire on Metrics, then the deltas are kept in historical table for 7 days by default Statistics Not to be confused  DBA_HIST_SYSMETRIC_HISTORY with the other metric  DBA_HIST_SESSMETRIC_HISTORY tables, these only Waits have values when  WAITCLASSMETRIC_HISTORY alerts fire File IO  DBA_HIST_FILEMETRIC_HISTORY Copyright 2006 Kyle Hailey #.27
  • Metrics Family of Tables Stats Waits FilesRaw V$sysstat v$system_event v$fileio v$event_histogram v$system_wait_classNow V$sysmetric v$eventmetric v$filemetric V$SYSMETRIC v$waitclassmetric V$SYSMETRIC_SUMMARY V$SESSMETRIC Session : v$sessmetric V$sysmetric_history v$waitclassmetric_history v$filemetric_history V$sysmetric_summary1 Hour DBA_HIST_WAITCLASSMETRIC_HISTORY DBA_HIST_FILEMETRIC_HISTORY DBA_HIST_SYSMETRIC_HISTORY7 days DBA_HIST_SESSMETRIC_HISTORY DBA_HIST_SQLSTATAlerts DBA_HIST_ DBA_HIST_SYSTEM_EVENTonly SYSMETRIC_SUMMARY Copyright 2006 Kyle Hailey #.28
  • 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 #.29
  • SnapshotingDone automatically out of the box, but can be run by hand: BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END; / dbms_workload_repository.drop_snapshot_range Copyright 2006 Kyle Hailey #.30
  • DBA_HISTDBA_HIST_DATABASE_INSTANCE DBA_HIST_RESOURCE_LIMITDBA_HIST_SNAPSHOT DBA_HIST_SHARED_POOL_ADVICE- DBA_HIST_SNAP_ERROR ?DBA_HIST_SQL_WORKAREA_HSTGRM- DBA_HIST_BASELINE DBA_HIST_PGA_TARGET_ADVICE- DBA_HIST_WR_CONTROL ? (work load repository ?) DBA_HIST_INSTANCE_RECOVERY- DBA_HIST_DATAFILE DBA_HIST_JAVA_POOL_ADVICEDBA_HIST_FILESTATXS – only file number, no name DBA_HIST_THREAD - logswitches- DBA_HIST_TEMPFILE -DBA_HIST_STAT_NAMEDBA_HIST_TEMPSTATXS – onl;y file number DBA_HIST_SYSSTAT+DBA_HIST_SQLSTAT group by parent cursor plus DELTAs was (stats$sql_summary) -DBA_HIST_SYS_TIME_MODELDBA_HIST_SQLTEXT -DBA_HIST_OSSTAT_NAME+DBA_HIST_SQL_SUMMARY – identify litterals (was stat$sql_statistics) -DBA_HIST_OSSTATDBA_HIST_SQL_PLAN DBA_HIST_PARAMETER_NAME-DBA_HIST_SQLBIND DBA_HIST_PARAMETER-DBA_HIST_SQLBIND_META - WRH$_SQL_BIND_METADATA DBA_HIST_SQLBIND_META DBA_HIST_UNDOSTAT-DBA_HIST_OPTIMIZER_ENV DBA_HIST_ROLLSTAT-DBA_HIST_EVENT_NAME DBA_HIST_SEG_STATDBA_HIST_SYSTEM_EVENT DBA_HIST_SEG_STAT_OBJ – object nameDBA_HIST_BG_EVENT_SUMMARY – sum of backgrounds -DBA_HIST_METRIC_NAMEDBA_HIST_WAITSTAT -DBA_HIST_SYSMETRIC_HISTORY alertDBA_HIST_ENQUEUE_STAT -DBA_HIST_SYSMETRIC_SUMMARY – max, min, avg standard-DBA_HIST_LATCH_NAME deviationDBA_HIST_LATCH -DBA_HIST_SESSMETRIC_HISTORY alertDBA_HIST_LATCH_CHILDREN -DBA_HIST_FILEMETRIC_HISTORY alertDBA_HIST_LATCH_PARENT -DBA_HIST_WAITCLASSMET_HISTORY alertDBA_HIST_LATCH_MISSES_SUMMARY – summed over parent latch DBA_HIST_DLM_MISCDBA_HIST_LIBRARYCACHE -DBA_HIST_RCVRY_FILE_DEST_STATDBA_HIST_DB_CACHE_ADVICE -DBA_HIST_RMAN_PERFORMANCEDBA_HIST_BUFFER_POOL_STAT -DBA_HIST_ACTIVE_SESS_HISTORY – every 10th point fromDBA_HIST_ROWCACHE_SUMMARY – summed over rowcache entries v$active_session_historyDBA_HIST_SGA -DBA_HIST_TABLESPACE_STATDBA_HIST_SGASTAT -DBA_HIST_LOGDBA_HIST_PGASTAT New in 10g DBA_HIST_MTTR_TARGET_ADVICE -DBA_HIST_TBSPC_SPACE_USAGE - ? Copyright 2006 Kyle Hailey #.31
  • Retention and Interval 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 #.32
  • AWR RPT @?/rdbms/admin/awrrpt.sql Creates Report File Similar to STATSPACK report More efficient and more data HTML or TEXT 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 #.33
  • AWR Report1) General info 1) General info 11) Advisories 12) Buffer Pool Stats 12) Buffer Pool Stats 11) Advisories2) Load Profile 2) Load Profile 1) Buffer pool 13) Wait Stats 13) Wait Stats 1) Buffer pool3) Wait Events 3) Wait Events 2) PGA 1) Buffer Busy 1) Buffer Busy 2) PGA4) OS Stats 4) OS Stats 3) Shared Pool 2) Enqueues 2) Enqueues 3) Shared Pool5) Service Stats 5) Service Stats 4) SGA 12) Undo Stats 12) Undo Stats 4) SGA6) Top SQL 6) Top SQL 5) Streams 13) Latch Stats 13) Latch Stats 5) Streams7) SQL Text 7) SQL Text 6) Java 14) Segment Stats 14) Segment Stats 6) Java8) Instance Statistic 8) Instance Statistic 15) Dictionary Stats 15) Dictionary Stats9) I/O Stat 9) I/O Stat 16) Library Cache 16) Library Cache10) Buffer Pool Stats 10) Buffer Pool Stats 17) Memory SGA/PGA 17) Memory SGA/PGA 18) Streams 18) Streams 19) Init.ora 19) Init.ora Copyright 2006 Kyle Hailey #.34
  • Awr 1-13 Copyright 2006 Kyle Hailey #.35
  • AWR 14-26 Copyright 2006 Kyle Hailey #.36
  • AWR DiffSELECT * 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 #.37
  • AWR Diff Report in OEM NOTE: Package AWR_DIFF_REPORT_HTML Is different from OEM Its just a tabular output Copyright 2006 Kyle Hailey #.38
  • 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 Copyright 2006 Kyle Hailey #.39
  • Important AWR Tables DBA_HIST_SQLSTAT  SQL deltas DBA_HIST_SEG_STAT  Segment deltas DBA_HIST_SYSMETRIC_SUMMARY  Stats, max, min, avg  Trending DBA_HIST_ACTIVE_SESS_HISTORY  ASH DBA_HIST_SYSTEM_EVENT  Waits dba_hist_sqltext – get sql text from AWR Copyright 2006 Kyle Hailey #.40
  • DBA_HIST_SNAPSHOTSQL> desc DBA_HIST_SNAPSHOTName Type------------------- -----------------------SNAP_ID NUMBERDBID NUMBERINSTANCE_NUMBER NUMBERSTARTUP_TIME TIMESTAMP(3)BEGIN_INTERVAL_TIME TIMESTAMP(3)END_INTERVAL_TIME TIMESTAMP(3)FLUSH_ELAPSED INTERVAL DAY(5) TO SECOND(1)SNAP_LEVEL NUMBERERROR_COUNT NUMBER Copyright 2006 Kyle Hailey #.41
  • DBA_HIST_SQLSTATSNAP_ID FETCHES_DELTADBID END_OF_FETCH_COUNT_DELTAINSTANCE_NUMBER SORTS_DELTASQL_ID EXECUTIONS_DELTA PX_SERVERS_EXECS_DELTAPLAN_HASH_VALUE LOADS_DELTAOPTIMIZER_COST INVALIDATIONS_DELTAOPTIMIZER_MODE PARSE_CALLS_DELTAOPTIMIZER_ENV_HASH_VALUE DISK_READS_DELTASHARABLE_MEM BUFFER_GETS_DELTALOADED_VERSIONS ROWS_PROCESSED_DELTAVERSION_COUNT CPU_TIME_DELTAMODULE ELAPSED_TIME_DELTAACTION IOWAIT_DELTASQL_PROFILE CLWAIT_DELTA APWAIT_DELTAFORCE_MATCHING_SIGNATURE CCWAIT_DELTAPARSING_SCHEMA_ID DIRECT_WRITES_DELTAPARSING_SCHEMA_NAME PLSEXEC_TIME_DELTABIND_DATA JAVEXEC_TIME_DELTA Copyright 2006 Kyle Hailey #.42
  • DBA_HIST_SEG_STAT Gets reset every DB bounceSQL> desc DBA_HIST_SEG_STAT PHYSICAL_WRITES_TOTAL PHYSICAL_WRITES_DELTAName PHYSICAL_READS_DIRECT_TOTALSNAP_ID PHYSICAL_READS_DIRECT_DELTADBID PHYSICAL_WRITES_DIRECT_TOTALINSTANCE_NUMBER PHYSICAL_WRITES_DIRECT_DELTATS# ITL_WAITS_TOTALOBJ# ITL_WAITS_DELTADATAOBJ# ROW_LOCK_WAITS_TOTALLOGICAL_READS_TOTAL ROW_LOCK_WAITS_DELTALOGICAL_READS_DELTA SPACE_USED_TOTALBUFFER_BUSY_WAITS_TOTAL SPACE_USED_DELTABUFFER_BUSY_WAITS_DELTA SPACE_ALLOCATED_TOTALDB_BLOCK_CHANGES_TOTAL SPACE_ALLOCATED_DELTADB_BLOCK_CHANGES_DELTA TABLE_SCANS_TOTALPHYSICAL_READS_TOTAL TABLE_SCANS_DELTAPHYSICAL_READS_DELTA Copyright 2006 Kyle Hailey #.43
  • 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 #.44
  • Average Wait Timesselect btime, (time_ms_end-time_ms_beg)/nullif(count_end-count_beg,0) avg_msfrom (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_begfrom DBA_HIST_SYSTEM_EVENT e, DBA_HIST_SNAPSHOT swhere BTIME AVG_MS s.snap_id=e.snap_id -------------------- ------------ and e.event_name= &1 08-JAN-08 01:00 1.017order by begin_interval_time 08-JAN-08 02:00 .720) 08-JAN-08 03:00 .621order by btime; 08-JAN-08 04:00 1.747 08-JAN-08 05:00 1.046 08-JAN-08 06:00 1.444 Copyright 2006 Kyle Hailey #.45
  • 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 #.46
  • ASH RPT1) General info 1) General info 9) Top SQL using literals 9) Top SQL using literals2) Top User Events *** 2) Top User Events *** 10) Top Sessions *** 10) Top Sessions ***3) Top Background Events 3) Top Background Events 11) Top Blocking Sessions 11) Top Blocking Sessions4) Top Event P1/P2/P3 Values 4) Top Event P1/P2/P3 Values 12) Top Sessions running PQs 12) Top Sessions running PQs5) Top Service/Module 5) Top Service/Module 13) Top DB Objects 13) Top DB Objects6) Top Client IDs 6) Top Client IDs 14) Top DB Files 14) Top DB Files7) Top SQL Command Types 7) Top SQL Command Types 15) Top Latches 15) Top Latches8) Top SQL Statements *** 8) Top SQL Statements *** 16) Activity Over Time *** 16) Activity Over Time *** Copyright 2006 Kyle Hailey #.47
  • ASH RPT HTML Copyright 2006 Kyle Hailey #.48
  • Time ModelNew concept• DB Time Time ModelTotal time for all database calls• cpu time SQL Wait• wait time Metrics Stats Sessions Copyright 2006 Kyle Hailey #.49
  • Time Model areas Total Time CPU  Updated every 5 seconds Elapsed Time SQL execution Plsql execution (sql execute subtracted out) Java execution Connection time  Probablythe most important as it points out problems with too many logons/sec Copyright 2006 Kyle Hailey #.50
  • 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 #.51
  • Total Time DB CPU DB Wait Time DB CPU ~ DB Total Database Wait Time Time Time Time Parse Elapsed Time Copyright 2006 Kyle Hailey #.52
  • Hard Parse Bind Mismatch hard parse (bind mismat hard ch) parse elapsed hard (sharing time parse criteria) Parse elapse elapsed time d time time elapsed Copyright 2006 Kyle Hailey #.53
  • Time Model TablesCurrent cumulative values V$SYS_TIME_MODEL V$SESS_TIME_MODELAWR Snapshots of cumulative values DBA_HIST_SYS_TIME_MODELTables show cumulative values. To find deltas, then needto run AWR report (no time model metric tables  ) Copyright 2006 Kyle Hailey #.54
  • Wait Classes Administrative (39)  Configuration (20)  switch logfile  log file size  rebuild index  Enqueues: ST, HW, ITL  Latch: redo copy,shared pool Application (11)  Idle (56)  enqueues sqlnet break/reset  Network (25)  Cluster (113) Commit (1)  System I/O (19)  Log file Sync  Scheduler (6) Concurrency (12)  User I/O (12)  Latches: cbc, lbc,   Lib cache locks Buffer busy wait  Other (485) Copyright 2006 Kyle Hailey #.55
  • 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 #.56
  • Waits Metrics Cumulative Current deltas Last Hour Last 7 days Wait v$system_wait_class Classes v$waitclassmetric v$waitclassmetric_history dba_hist_ WAIT_CLASS_ID BEGIN_TIME BEGIN_TIME waitclassmetric_history WAIT_CLASS# END_TIME END_TIME WAIT_CLASS INTSIZE_CSEC INTSIZE_CSEC Only gets populated with alerts TOTAL_WAITS WAIT_CLASS_ID WAIT_CLASS_ID TIME_WAITED WAIT_CLASS# WAIT_CLASS# NUM_SESS_WAITING NUM_SESS_WAITINGv$event_name TIME_WAITED TIME_WAITEDEVENT# WAIT_COUNT WAIT_COUNTEVENT_IDNAMEPARAMETER1PARAMETER2PARAMETER3WAIT_CLASS_IDWAIT_CLASS#WAIT_CLASS Wait Events v$system_event v$eventmetric dba_hist_system_event BEGIN_TIME EVENT END_TIME (Cumulative) TOTAL_WAITS INTSIZE_CSEC TOTAL_TIMEOUTS EVENT_ID No in memory history NUM_SESS_WAITING TIME_WAITED TIME_WAITED AVERAGE_WAIT WAIT_COUNT TIME_WAITED_MICRO EVENT_ID Copyright 2006 Kyle Hailey #.57
  • Miscellaneous  V$sqlstats  Field naming conventions  Wait Improvements  Wait histograms  Waits in v$session and v$sql  Waits show the blocker  Wait history of last 10 waits  Services  Client Id Copyright 2006 Kyle Hailey #.58
  • v$sqlstats More efficient than v$sql or v$sqlarea Uses less CPU Faster Skips many of the latch gets that v$sql does Uses Mutexes instead of some latches Copyright 2006 Kyle Hailey #.59
  • Event and Stat Fields Names  Names SQL  Event  Statistic SQL_ID new hash  Waitclass HASH_VALUE still there  Ids  Event#  Statistic#  Waitclass#  Name Hash  Event_id  Statistic_id  Waitclass_id Copyright 2006 Kyle Hailey #.60
  • Wait HistogramsV$event_histogram 1ms to 1 hour buckets 23 buckets < 1 ms, < 2 ms, < 4 ms, < 8 ms, ..., < 2^22 ms Copyright 2006 Kyle Hailey #.61
  • Waits in v$session V$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) Copyright 2006 Kyle Hailey #.62
  • 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 #.63
  • Waits show Blocking SessionV$session. BLOCKING_SESSION -> can build a wait tree: Copyright 2006 Kyle Hailey #.64
  • 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 #.65
  • Setting up Services jdbc:oracle:thin:@//server:1521/SERVICE_NAMEdbms_service.CREATE_SERVICE(ora10a,‘A);dbms_service.START_SERVICE (ora10a);-- dbms_service.STOP_SERVICE (ora10a);-- dbms_service.DELETE_SERVICE(ora10a); NametnsA = tracked (DESCRIPTION = tnsnames.ora (ADDRESS_LIST = in OEM (ADDRESS = (PROTOCOL = TCP) (HOST = kylehpd)(PORT = 1521)) ) Sqlplus un/pw@tnsA (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = A) ) ) lsnrctl servicesService "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 #.66
  • Services in OEM Enable Trace By Service View doesn’t work Copyright 2006 Kyle Hailey #.67
  • 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(client_id) Script to Extract Client Trace Trcsess output=<name> client_id=<name> * Copyright 2006 Kyle Hailey #.68
  • Session Dedicated Scott John Sue Mike Randy Tim Mary Oracle S1 S2 S3 S4 S4 S5 S6Sessions Oracle Database Host Copyright 2006 Kyle Hailey #.69
  • Session Dedicated trace Scott John Sue Mike Randy Tim Mary SQL_TRACE=TRUE Oracle S1 S2 S3 S4 S4 S5 S6Sessions Oracle Database Host Copyright 2006 Kyle Hailey #.70
  • Session Pooling trace Scott John Sue Mike Randy Tim Mary APP Server 1 S1, sql_trace=true Oracle S1 S2 S3 S4 S4 S5 S6 S7Sessions Oracle Database Host Copyright 2006 Kyle Hailey #.71
  • Session Pooling Scott John Sue Mike Randy Tim Mary Set client_id = SCOTT dbms_monitor.client_id_trace_enable APP (client_id, TRUE, FALSE); Server waits, binds 1 Oracle S1 S2 S3 S4 S4 S5 S6 S7Sessions Oracle Database Host Copyright 2006 Kyle Hailey #.72
  • DB_FILE_MULTI_BLOCK_READ_COUNT  Auto tuned in 10gR2  Recommended to leave unset in init.ora, ex, when unset on my PC  db_file_multiblock_read_count 55  _db_file_exec_read_count 55 (IO reads)  _db_file_optimizer_read_count 8 (optimization)  When running  Dbms_stats.gather_system_stats(gathering_mode => ‘interval’ interval => 30 ) db_file_multiblock_read_count is ignored  Alter system reset db_file_multiblock_read_count scope=spfile sid=‘*’; Troubleshooting Oracle Performance Christian Antognini Copyright 2006 Kyle Hailey #.73
  • 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 miscalculated and UNDO can grow, fixed 10.2.0.4  10.2.0.3 or below can set  alter system set "_smu_debug_mode" = 33554432 Copyright 2006 Kyle Hailey #.74
  • SQL Trace Improvement dbms_monitor New 10g dbms_monitor.session_trace_enable(session_id => 127, serial_num => 29, waits => TRUE, binds => FALSE)10gR2 v$session columns sql_trace sql_trace_waits sql_trace_bindsare set when the proceduresession_trace_enable is used and at least one SQL statement has been executed by thesessionvtraced Instead of alter session set events ‘10046 trace name context forever, level 12; Copyright 2006 Kyle Hailey #.75
  • Q1An ASH report can be run on data covering what timeperiods (by default)a. any 60 seconds in the past weekb. any hour period in the past dayc. any day in the past weekd. any 60 second period in the past hour answers all the above Copyright 2006 Kyle Hailey #.76
  • Q2AWR ( automatic workload repository ) reports on datacoveringwhat time periods (by default)a. any 60 seconds in the past weekb. any hour period in the past dayc. any day in the past weekd. any 60 second period in the past hour answers b and c - AWR only takes data every hour for a week by default Copyright 2006 Kyle Hailey #.77
  • Q3Connecting to Oracle is a CPU intensive operation. A highlogon ratemay indicate an application design issue that unnecessarilyburns CPU.What performance table(s) indicates the time spentconnecting to the database ? b - onlya. v$active_session_history othersb. v$sys_time_model a,c,d - dont reportc. v$waitclassmetric connection time or connectd. v$sysstat CPU usage Copyright 2006 Kyle Hailey #.78
  • Q4What is the least resource consuming view for getting thenumberof executions of an sql statement b - new in 10g, less latch usage than the othera. v$sqllite tablesb. v$sqlstats othersc. v$sql a doesnt exitd. v$sqlarea c reading uses many of the latches as users executing sql d the worst, like v$sql, but also does an expensive group by Hailey Copyright 2006 Kyle #.79
  • Q5How can you immediately find the top CPU consumingsession in the past 15 secondsa. v$sessmetric answerb. v$active_session_history a, bc. v$sesstat others:d. v$top_sessions c - only has cumulative data, need to take deltas of values to see what is happening d - doesnt exist Copyright 2006 Kyle Hailey #.80
  • Q6What script runs 16 different queries againstv$active_session_history toproduce a detailed report over any time interval in the AWRrepository answera. ?/rdbms/admin/spreport.sql cb. ?/rdbms/admin/awrrpt.sql otherc. ?/rdbms/admin/ashrpt.sqld. ?/rdbms/admin/ashreport.sql ASH a and b dont use d doesnt exit Copyright 2006 Kyle Hailey #.81
  • Q7In 10g, it is recommended to setdb_file_multiblock_read_count to answera. unset a. Oracle will set it automatically to the optimalb. 8 valuec. 16 (this wont affect SQL optimization as Oracle will calculated. 32 sql optimization withe. 128 _db_file_optimizer_read_count ) Copyright 2006 Kyle Hailey #.82
  • Q8Oracle can track different applications using the "servicesidentifier.After the service identifier gets created and started, howdoes theservices identifier get set for a connection.a. call to dbms_servicesb. via the tnsnames.ora connectionc. in the init.ora answerd. via a middle tier command b Copyright 2006 Kyle Hailey #.83
  • Q9The identifier "client_id" allows a DBA to monitor whatspecial situation:a. track different applications resource usage on a databaseb. track application users in session poolsc. track dedicated sessionsd. is the same as the database "username" answer b - set up specifically to track application users that connect without a dedicated connection vi a session pool Copyright 2006 Kyle Hailey #.84