Wait Events 10g

4,257 views
4,196 views

Published on

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,257
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
253
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Wait Events 10g

  1. 1. Wait Event Enhancements in Oracle 10g Terry Sutton and Roger Schrag Database Specialists, Inc. www.dbspecialists.com
  2. 2. Today’s Session <ul><li>Twelve wait event interface enhancements in Oracle 10g that we really like. </li></ul><ul><ul><li>Documentation gaps in some areas make this information harder to come by. </li></ul></ul><ul><li>We will assume everyone is familiar with wait event concepts and the wait event interface in Oracle 9i or earlier. </li></ul><ul><li>To learn more about wait events, read: www.dbspecialists.com/presentations.html#wait_events </li></ul>
  3. 3. White Paper <ul><li>Contains additional detail we won’t have time to cover today. </li></ul><ul><li>Includes a handy reference list of all Oracle 10g wait events, wait classes, and wait event parameters. </li></ul><ul><li>Download: www.dbspecialists.com/presentations </li></ul>
  4. 4. Twelve Oracle 10g Enhancements <ul><ul><ul><li>More descriptive wait event names </li></ul></ul></ul><ul><ul><ul><li>Wait event classes </li></ul></ul></ul><ul><ul><ul><li>v$event_name new columns </li></ul></ul></ul><ul><ul><ul><li>v$sql / v$sqlarea new columns </li></ul></ul></ul><ul><ul><ul><li>v$session_wait_history </li></ul></ul></ul><ul><ul><ul><li>v$session new columns </li></ul></ul></ul><ul><ul><ul><li>v$event_histogram </li></ul></ul></ul><ul><ul><ul><li>v$system_wait_class / v$session_wait_class </li></ul></ul></ul><ul><ul><ul><li>Active Session History (ASH) </li></ul></ul></ul><ul><ul><ul><li>Automatic Workload Repository (AWR) </li></ul></ul></ul><ul><ul><ul><li>Time model statistics </li></ul></ul></ul><ul><ul><ul><li>Improved session tracing </li></ul></ul></ul>
  5. 5. More Descriptive Names <ul><li>Prior to Oracle 10g many wait events had vague names that covered many situations: </li></ul><ul><ul><li>latch free </li></ul></ul><ul><ul><li>enqueue </li></ul></ul><ul><ul><li>buffer busy waits </li></ul></ul><ul><li>For these waits you had to look at parameter values to learn the wait condition. </li></ul><ul><li>Oracle 10g gives the most common of these types of waits more descriptive names. </li></ul>
  6. 6. latch free <ul><li>Prior to Oracle 10g: Could indicate a wait on any of dozens of different latches. </li></ul><ul><li>Oracle 10g: The 26 most common latches have their own wait event. </li></ul><ul><ul><li>The rest continue to use the generic “latch free” wait event. </li></ul></ul>
  7. 7. latch free Prior to Oracle 10g <ul><li>SQL> SELECT event, state, p1, p2, p3 FROM v$session_wait WHERE sid = 162; </li></ul><ul><li>EVENT STATE P1 P2 P3 </li></ul><ul><li>------------- ------- ----------- ------ ----- </li></ul><ul><li>latch free WAITING 15113593728 97 5 </li></ul><ul><li>SQL> SELECT * FROM v$event_name WHERE name = 'latch free'; </li></ul><ul><li>EVENT# NAME PARAMETER1 PARAMETER2 PARAMETER3 </li></ul><ul><li>------ ---------- --------------- --------------- --------------- </li></ul><ul><li>3 latch free address number tries </li></ul><ul><li>SQL> SELECT name FROM v$latch WHERE latch# = 97; </li></ul><ul><li>NAME </li></ul><ul><li>-------------------- </li></ul><ul><li>cache buffers chains </li></ul>
  8. 8. latch free in Oracle 10g <ul><li>SQL> SELECT event, state </li></ul><ul><li>2 FROM v$session_wait </li></ul><ul><li>3 WHERE sid = 162; </li></ul><ul><li>EVENT STATE </li></ul><ul><li>------------------------------ ------- </li></ul><ul><li>latch: cache buffers chains WAITING </li></ul><ul><li>The more descriptive wait event name saves us the effort of decoding wait event parameters. </li></ul>
  9. 9. enqueue <ul><li>Prior to Oracle 10g: Could indicate a wait on any of a few dozen different types of enqueues. </li></ul><ul><li>Oracle 10g: 184 distinct wait events replace the one generic “enqueue” wait event: </li></ul><ul><ul><li>Event names differentiate the enqueue type and sometimes even the contention type. </li></ul></ul><ul><ul><li>Parameter names are more descriptive than generic “id1” and “id2”. </li></ul></ul>
  10. 10. enqueue Prior to Oracle 10g <ul><li>SQL> SELECT event, state, seconds_in_wait FROM v$session_wait WHERE sid = 96; </li></ul><ul><li>EVENT STATE SECONDS_IN_WAIT </li></ul><ul><li>----------------------------------- ------------------- --------------- </li></ul><ul><li>enqueue WAITING 24 </li></ul><ul><li>SQL> SELECT sid, CHR (BITAND (p1,-16777216) / 16777215) || </li></ul><ul><li>2 CHR (BITAND (p1, 16711680) / 65535) enq, </li></ul><ul><li>3 DECODE (CHR (BITAND (p1,-16777216) / 16777215) || </li></ul><ul><li>4 CHR (BITAND (p1, 16711680) / 65535), </li></ul><ul><li>5 'TX', 'Transaction (RBS)', </li></ul><ul><li>... </li></ul><ul><li>13 CHR (BITAND (p1, 16711680) / 65535)) enqueue_name, </li></ul><ul><li>14 DECODE (BITAND (p1, 65535), 1, 'Null', 2, 'Sub-Share', </li></ul><ul><li>15 3, 'Sub-Exclusive', 4, 'Share', 5, 'Share/Sub-Exclusive', </li></ul><ul><li>16 6, 'Exclusive', 'Other') lock_mode </li></ul><ul><li>17 FROM v$session_wait WHERE sid = 96; </li></ul><ul><li>SID ENQ ENQUEUE_NAME LOCK_MODE </li></ul><ul><li>----- ---- ------------------------------ ---------- </li></ul><ul><li>96 TX Transaction (RBS) Exclusive </li></ul>
  11. 11. enqueue in Oracle 10g <ul><li>SQL> SELECT event, state, seconds_in_wait FROM v$session_wait WHERE sid = 143; </li></ul><ul><li>EVENT STATE SECONDS_IN_WAIT </li></ul><ul><li>----------------------------------- ------------------- --------------- </li></ul><ul><li>enq: TX - row lock contention WAITING 495 </li></ul><ul><li>Separate events for separate TX issues: </li></ul><ul><li>SQL> SELECT name, parameter1, parameter2, parameter3 </li></ul><ul><li>2 FROM v$event_name </li></ul><ul><li>3 WHERE name LIKE 'enq: TX%'; </li></ul><ul><li>NAME PARAMETER1 PARAMETER2 PARAMETER3 </li></ul><ul><li>------------------------------ ------------- --------------- ------------- </li></ul><ul><li>enq: TX - contention name|mode usn<<16 | slot sequence </li></ul><ul><li>enq: TX - row lock contention name|mode usn<<16 | slot sequence </li></ul><ul><li>enq: TX - allocate ITL entry name|mode usn<<16 | slot sequence </li></ul><ul><li>enq: TX - index contention name|mode usn<<16 | slot sequence </li></ul>
  12. 12. enqueue in Oracle 10g <ul><li>More descriptive parameter names, too: </li></ul><ul><li>SQL> SELECT name, parameter1, parameter2, parameter3 </li></ul><ul><li>2 FROM v$event_name </li></ul><ul><li>3 WHERE name IN ('enq: HW - contention', 'enq: SQ - contention'); </li></ul><ul><li>NAME PARAMETER1 PARAMETER2 PARAMETER3 </li></ul><ul><li>------------------------------ ------------- --------------- ------------- </li></ul><ul><li>enq: HW - contention name|mode table space # block </li></ul><ul><li>enq: SQ - contention name|mode object # 0 </li></ul>
  13. 13. Wait Event Classes <ul><li>Every wait event belongs to one of 12 classes. </li></ul><ul><li>Classes can help point toward a root cause. </li></ul><ul><li>Almost 70% of all wait events belong to a class called “Other.” </li></ul><ul><li>Most of the wait events that occur frequently belong to wait event classes with helpful names. </li></ul>
  14. 14. Wait Event Class Names Other Configuration User I/O Concurrency System I/O Commit Scheduler Cluster Network Application Idle Administrative
  15. 15. Wait Class Assignments <ul><li>SQL> SELECT wait_class, name </li></ul><ul><li>2 FROM v$event_name </li></ul><ul><li>3 WHERE name LIKE 'enq: TX%' </li></ul><ul><li>4 ORDER BY wait_class, name; </li></ul><ul><li>WAIT_CLASS NAME </li></ul><ul><li>--------------- ---------------------------------------- </li></ul><ul><li>Application enq: TX - row lock contention </li></ul><ul><li>Concurrency enq: TX - index contention </li></ul><ul><li>Configuration enq: TX - allocate ITL entry </li></ul><ul><li>Other enq: TX - contention </li></ul>
  16. 16. v$event_name <ul><li>Three new columns show which wait class a wait event belongs to: </li></ul><ul><li>SQL> DESCRIBE v$event_name </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- ------------------- </li></ul><ul><li>EVENT# NUMBER </li></ul><ul><li>EVENT_ID NUMBER </li></ul><ul><li>NAME VARCHAR2(64) </li></ul><ul><li>PARAMETER1 VARCHAR2(64) </li></ul><ul><li>PARAMETER2 VARCHAR2(64) </li></ul><ul><li>PARAMETER3 VARCHAR2(64) </li></ul><ul><li>WAIT_CLASS_ID NUMBER </li></ul><ul><li>WAIT_CLASS# NUMBER </li></ul><ul><li>WAIT_CLASS VARCHAR2(64) </li></ul>
  17. 17. v$sql and v$sqlarea <ul><li>Six new columns give more information about how time was spent executing a SQL statement: </li></ul><ul><ul><li>application_wait_time </li></ul></ul><ul><ul><li>concurrency_wait_time </li></ul></ul><ul><ul><li>cluster_wait_time </li></ul></ul><ul><ul><li>user_io_wait_time </li></ul></ul><ul><ul><li>plsql_exec_time </li></ul></ul><ul><ul><li>java_exec_time </li></ul></ul><ul><li>Times are in microseconds. </li></ul>
  18. 18. v$sqlarea Example <ul><li>In session #1: </li></ul><ul><li>SQL> UPDATE testtab SET numcol = numcol + 1 WHERE ROWNUM < 1000; </li></ul><ul><li>In session #2: </li></ul><ul><li>SQL> UPDATE testtab SET numcol = numcol + 1 WHERE ROWNUM < 1000; </li></ul><ul><li>In session #1: </li></ul><ul><li>SQL> ROLLBACK; </li></ul><ul><li>In session #2: </li></ul><ul><li>SQL> ROLLBACK; </li></ul><ul><li>In session #3: </li></ul><ul><li>SQL> UPDATE testtab SET numcol = numcol + 1; </li></ul>
  19. 19. v$sqlarea Example <ul><li>SQL> SELECT sql_id, application_wait_time appl, </li></ul><ul><li>2 concurrency_wait_time concurr, user_io_wait_time user_io </li></ul><ul><li>3 FROM v$sqlarea </li></ul><ul><li>4 WHERE sql_text LIKE 'UPDATE testtab SET numcol%'; </li></ul><ul><li>SQL_ID APPL CONCURR USER_IO </li></ul><ul><li>------------- --------- --------- ----------- </li></ul><ul><li>038m56cp4am0c 178500000 0 20000 </li></ul><ul><li>fd5mxhdbf09ny 0 10000 105040000 </li></ul><ul><li>SQL> SELECT sql_id, sql_text </li></ul><ul><li>2 FROM v$sqlarea </li></ul><ul><li>3 WHERE sql_id IN ('fd5mxhdbf09ny','038m56cp4am0c'); </li></ul><ul><li>SQL_ID SQL_TEXT </li></ul><ul><li>------------- ----------------------------------------------------------- </li></ul><ul><li>038m56cp4am0c UPDATE testtab SET numcol = numcol + 1 WHERE ROWNUM < 1000 </li></ul><ul><li>fd5mxhdbf09ny UPDATE testtab SET numcol = numcol + 1 </li></ul>
  20. 20. v$session_wait_history <ul><li>New view in Oracle 10g. </li></ul><ul><li>Similar to v$session_wait, but shows the last ten wait events for each session. </li></ul><ul><li>The seq# column is supposed to show the order in which the waits occurred, with 1 being the most recent wait: </li></ul><ul><ul><li>Different from seq# in v$session. </li></ul></ul><ul><ul><li>Does not appear to work as documented (on our 10.1.0.3 system on Solaris). </li></ul></ul>
  21. 21. v$session_wait_history <ul><li>SQL> DESCRIBE v$session_wait_history </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- -------------------------- </li></ul><ul><li>SID NUMBER </li></ul><ul><li>SEQ# NUMBER </li></ul><ul><li>EVENT# NUMBER </li></ul><ul><li>EVENT VARCHAR2(64) </li></ul><ul><li>P1TEXT VARCHAR2(64) </li></ul><ul><li>P1 NUMBER </li></ul><ul><li>P2TEXT VARCHAR2(64) </li></ul><ul><li>P2 NUMBER </li></ul><ul><li>P3TEXT VARCHAR2(64) </li></ul><ul><li>P3 NUMBER </li></ul><ul><li>WAIT_TIME NUMBER </li></ul><ul><li>WAIT_COUNT NUMBER </li></ul>
  22. 22. v$session_wait_history Example <ul><li>SQL> SELECT sid, seq#, event, wait_time, p1, p2, p3 </li></ul><ul><li>2 FROM v$session_wait_history </li></ul><ul><li>3 WHERE sid = 154 </li></ul><ul><li>4 ORDER BY seq#; </li></ul><ul><li>SID SEQ# EVENT WAIT_TIME P1 P2 P3 </li></ul><ul><li>--- ---- ------------------------ ---------- ------ ------ ------ </li></ul><ul><li>154 1 db file sequential read 28 4 3547 1 </li></ul><ul><li>154 2 log buffer space 18 0 0 0 </li></ul><ul><li>154 3 log buffer space 36 0 0 0 </li></ul><ul><li>154 4 db file sequential read 0 4 3559 1 </li></ul><ul><li>154 5 db file sequential read 0 4 1272 1 </li></ul><ul><li>154 6 db file sequential read 0 4 3555 1 </li></ul><ul><li>154 7 log buffer space 9 0 0 0 </li></ul><ul><li>154 8 db file sequential read 0 4 3551 1 </li></ul><ul><li>154 9 db file sequential read 6 4 1268 1 </li></ul><ul><li>154 10 log buffer space 8 0 0 0 </li></ul>
  23. 23. v$session <ul><li>All columns from v$session_wait have been added to v$session: </li></ul><ul><ul><li>Saves us the effort of joining the two views.. </li></ul></ul><ul><li>New blocking_session, blocking_session_status columns: </li></ul><ul><ul><li>blocking_session shows the SID of the session holding the resource blocking this session. </li></ul></ul><ul><ul><li>blocking_session_status contains ‘VALID’ when blocking_session is populated. </li></ul></ul>
  24. 24. v$session Example <ul><li>Prior to Oracle 10g: </li></ul><ul><li>SQL> SELECT s.sid, w.state, w.event, w.seconds_in_wait siw, </li></ul><ul><li>2 s.sql_address, s.sql_hash_value hash_value, w.p1, w.p2, w.p3 </li></ul><ul><li>3 FROM v$session s, v$session_wait w </li></ul><ul><li>4 WHERE s.sid = w.sid </li></ul><ul><li>5 AND s.sid = 154; </li></ul><ul><li>Oracle 10g: </li></ul><ul><li>SQL> SELECT sid, state, event, seconds_in_wait siw, </li></ul><ul><li>2 sql_address, sql_hash_value hash_value, p1, p2, p3 </li></ul><ul><li>3 FROM v$session </li></ul><ul><li>4 WHERE sid = 154; </li></ul>
  25. 25. Another Example <ul><li>Why is session 154 waiting? And who is blocking session 154? </li></ul><ul><li>SQL> SELECT sid, blocking_session, blocking_session_status block_status, </li></ul><ul><li>2 username, event, seconds_in_wait siw </li></ul><ul><li>3 FROM v$session </li></ul><ul><li>4 WHERE sid = 154; </li></ul><ul><li>BLOCKING </li></ul><ul><li>SID _SESSION BLOCK_STATUS USERNAME EVENT SIW </li></ul><ul><li>--- -------- ------------ -------- ------------------------------ --- </li></ul><ul><li>154 157 VALID TSUTTON enq: TX - row lock contention 318 </li></ul>
  26. 26. v$event_histogram <ul><li>New view in Oracle 10g. </li></ul><ul><li>Shows instance-wide summary wait event statistics like v$system_event, but provides a wait time histogram for each. Buckets: </li></ul><ul><ul><li>Less than 1 mS. </li></ul></ul><ul><ul><li>1 mS to 2 mS. </li></ul></ul><ul><ul><li>2 mS to 4 mS. </li></ul></ul><ul><ul><li>4 mS to 8 mS. </li></ul></ul><ul><ul><li>... and so on </li></ul></ul>
  27. 27. v$event_histogram <ul><li>SQL> DESCRIBE v$event_histogram </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- --------------------------- </li></ul><ul><li>EVENT# NUMBER </li></ul><ul><li>EVENT VARCHAR2(64) </li></ul><ul><li>WAIT_TIME_MILLI NUMBER </li></ul><ul><li>WAIT_COUNT NUMBER </li></ul>
  28. 28. v$event_histogram Example <ul><li>How significant is the row lock contention on our system? </li></ul><ul><li>SQL> SELECT event, total_waits, time_waited, average_wait </li></ul><ul><li>2 FROM v$system_event </li></ul><ul><li>3 WHERE event = 'enq: TX - row lock contention'; </li></ul><ul><li>EVENT TOTAL_WAITS TIME_WAITED AVERAGE_WAIT </li></ul><ul><li>----------------------------- ----------- ----------- ------------ </li></ul><ul><li>enq: TX - row lock contention 17218 2101966 122 </li></ul><ul><li>Does the average wait of 1.22 seconds indicated by v$system_event paint an accurate picture? </li></ul>
  29. 29. v$event_histogram Example <ul><li>SQL> SELECT event, wait_time_milli, wait_count </li></ul><ul><li>2 FROM v$event_histogram </li></ul><ul><li>3 WHERE event = 'enq: TX - row lock contention'; </li></ul><ul><li>EVENT WAIT_TIME_MILLI WAIT_COUNT </li></ul><ul><li>----------------------------- --------------- ---------- </li></ul><ul><li>enq: TX - row lock contention 1 833 </li></ul><ul><li>enq: TX - row lock contention 2 635 </li></ul><ul><li>enq: TX - row lock contention 4 372 </li></ul><ul><li>enq: TX - row lock contention 8 395 </li></ul><ul><li>enq: TX - row lock contention 16 781 </li></ul><ul><li>enq: TX - row lock contention 32 3729 </li></ul><ul><li>enq: TX - row lock contention 64 3050 </li></ul><ul><li>enq: TX - row lock contention 128 410 </li></ul><ul><li>enq: TX - row lock contention 256 47 </li></ul><ul><li>enq: TX - row lock contention 512 46 </li></ul><ul><li>enq: TX - row lock contention 1024 37 </li></ul><ul><li>enq: TX - row lock contention 2048 3 </li></ul><ul><li>enq: TX - row lock contention 4096 6880 </li></ul>
  30. 30. v$system_wait_class and v$session_wait_class <ul><li>New views in Oracle 10g. </li></ul><ul><li>Show wait counts and total time waited since instance startup and session start. </li></ul><ul><li>Similar to v$system_event and v$session_event, but summarized by wait class. </li></ul><ul><li>Times are in centiseconds. </li></ul>
  31. 31. v$system_wait_class and v$session_wait_class <ul><li>SQL> DESCRIBE v$system_wait_class </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- --------------------------- </li></ul><ul><li>WAIT_CLASS_ID NUMBER </li></ul><ul><li>WAIT_CLASS# NUMBER </li></ul><ul><li>WAIT_CLASS VARCHAR2(64) </li></ul><ul><li>TOTAL_WAITS NUMBER </li></ul><ul><li>TIME_WAITED NUMBER </li></ul><ul><li>SQL> DESCRIBE v$session_wait_class </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- --------------------------- </li></ul><ul><li>SID NUMBER </li></ul><ul><li>SERIAL# NUMBER </li></ul><ul><li>WAIT_CLASS_ID NUMBER </li></ul><ul><li>WAIT_CLASS# NUMBER </li></ul><ul><li>WAIT_CLASS VARCHAR2(64) </li></ul><ul><li>TOTAL_WAITS NUMBER </li></ul><ul><li>TIME_WAITED NUMBER </li></ul>
  32. 32. v$system_wait_class Example <ul><li>SQL> SELECT wait_class, time_waited </li></ul><ul><li>2 FROM v$system_wait_class </li></ul><ul><li>3 ORDER BY time_waited DESC; </li></ul><ul><li>WAIT_CLASS TIME_WAITED </li></ul><ul><li>------------- ----------- </li></ul><ul><li>Idle 777450022 </li></ul><ul><li>System I/O 1261584 </li></ul><ul><li>User I/O 116667 </li></ul><ul><li>Configuration 116481 </li></ul><ul><li>Application 72301 </li></ul><ul><li>Other 12432 </li></ul><ul><li>Commit 3496 </li></ul><ul><li>Concurrency 319 </li></ul><ul><li>Network 1 </li></ul>
  33. 33. Active Session History <ul><li>New MMNL background process samples v$session once each second. </li></ul><ul><li>Data captured on active sessions is available in v$active_session_history, usually for 1-4+ hours. </li></ul><ul><li>Automatic Workload Repository captures one out of every ten samples in its hourly snapshots. </li></ul>
  34. 34. Active Session History <ul><li>SQL> DESCRIBE v$active_session_history </li></ul><ul><li>Name Null? Type </li></ul><ul><li>----------------------------------------- -------- --------------------------- </li></ul><ul><li>SAMPLE_ID NUMBER </li></ul><ul><li>SAMPLE_TIME TIMESTAMP(3) </li></ul><ul><li>SESSION_ID NUMBER </li></ul><ul><li>SESSION_SERIAL# NUMBER </li></ul><ul><li>USER_ID NUMBER </li></ul><ul><li>SQL_ID VARCHAR2(13) </li></ul><ul><li>SQL_CHILD_NUMBER NUMBER </li></ul><ul><li>SQL_PLAN_HASH_VALUE NUMBER </li></ul><ul><li>SQL_OPCODE NUMBER </li></ul><ul><li>SERVICE_HASH NUMBER </li></ul><ul><li>SESSION_TYPE VARCHAR2(10) </li></ul><ul><li>SESSION_STATE VARCHAR2(7) </li></ul><ul><li>QC_SESSION_ID NUMBER </li></ul><ul><li>QC_INSTANCE_ID NUMBER </li></ul><ul><li>EVENT VARCHAR2(64) </li></ul><ul><li>EVENT_ID NUMBER </li></ul><ul><li>EVENT# NUMBER </li></ul><ul><li>SEQ# NUMBER </li></ul><ul><li>P1 NUMBER </li></ul><ul><li>P2 NUMBER </li></ul><ul><li>P3 NUMBER </li></ul><ul><li>WAIT_TIME NUMBER </li></ul><ul><li>TIME_WAITED NUMBER </li></ul><ul><li>CURRENT_OBJ# NUMBER </li></ul><ul><li>CURRENT_FILE# NUMBER </li></ul><ul><li>CURRENT_BLOCK# NUMBER </li></ul><ul><li>PROGRAM VARCHAR2(48) </li></ul><ul><li>MODULE VARCHAR2(48) </li></ul><ul><li>ACTION VARCHAR2(32) </li></ul><ul><li>CLIENT_ID VARCHAR2(64) </li></ul>
  35. 35. Active Session History <ul><li>v$active_session_history shows detailed wait information, current SQL statement, object/file/block information, and more. </li></ul><ul><li>When a wait that was sampled by ASH completes, Oracle fills in the time_waited column in the v$active_session_history row with the actual duration of the wait. </li></ul>
  36. 36. ASH is “Always On” <ul><li>You may not have to turn on tracing or begin monitoring v$ views when users report a problem, because ASH is already sampling data. </li></ul><ul><li>In some cases you may be able to diagnose and resolve a problem on first detection, even if you learn of the problem after the fact. </li></ul><ul><ul><li>You may not need to get users to reproduce the problem. </li></ul></ul>
  37. 37. Sampling versus Collecting <ul><li>ASH samples v$session once each second. Very different from extended SQL trace, which collects data on every wait and every OCI call. </li></ul><ul><ul><li>A session could encounter hundreds of waits in one second, and ASH will only capture data for one of them. </li></ul></ul><ul><li>Use ASH to view aggregate data on many sessions over a period of time. </li></ul><ul><li>Don’t use ASH to count waits, get maximum wait times, or look at a short time period. </li></ul>
  38. 38. ASH Example <ul><li>SQL> SELECT DECODE (session_state, 'WAITING', event, NULL) event, </li></ul><ul><li>2 session_state, COUNT(*), SUM (time_waited) time_waited </li></ul><ul><li>3 FROM v$active_session_history </li></ul><ul><li>4 WHERE module = 'ARXENV' </li></ul><ul><li>5 AND sample_time > SYSDATE - (2/24) </li></ul><ul><li>6 GROUP BY DECODE (session_state, 'WAITING', event, NULL), </li></ul><ul><li>7 session_state; </li></ul><ul><li>EVENT SESSION_STATE COUNT(*) TIME_WAITED </li></ul><ul><li>------------------------------ ------------- -------- ----------- </li></ul><ul><li>ON CPU 124 0 </li></ul><ul><li>log file sync WAITING 2 52686 </li></ul><ul><li>db file scattered read WAITING 2 28254 </li></ul><ul><li>db file sequential read WAITING 1 6059 </li></ul><ul><li>control file sequential read WAITING 1 9206 </li></ul><ul><li>SQL*Net break/reset to client WAITING 1 9140 </li></ul><ul><li>enq: TX - row lock contention WAITING 922 930864016 </li></ul>
  39. 39. Automatic Workload Repository <ul><li>Conceptually similar to Statspack. </li></ul><ul><li>Collects “snapshots” of system-wide performance statistics, plus ASH’s sampling of session activity. </li></ul><ul><li>You can generate activity reports using awrrpt.sql or Enterprise Manager interface. </li></ul><ul><li>Out of the box, Oracle 10g databases collect snapshots hourly and retain data for seven days. </li></ul>
  40. 40. AWR Management <ul><li>Snapshot data is stored in SYS-owned tables in the SYSAUX tablespace. </li></ul><ul><li>Use dbms_workload_repository to: </li></ul><ul><ul><li>Collect a snapshot on demand. </li></ul></ul><ul><ul><li>Purge snapshots. </li></ul></ul><ul><ul><li>Adjust snapshot interval. </li></ul></ul><ul><ul><li>Adjust snapshot retention period. </li></ul></ul><ul><ul><li>Disable AWR snapshot collection. </li></ul></ul>
  41. 41. AWR versus Statspack <ul><li>AWR benefits: </li></ul><ul><ul><li>More tightly integrated into Oracle kernel, reducing snapshot collection overhead. </li></ul></ul><ul><ul><li>Snapshots include sampling of ASH data. </li></ul></ul><ul><ul><li>Data collected by AWR is accessible via views with names starting DBA_HIST. </li></ul></ul><ul><ul><li>DBA_HIST views are documented. </li></ul></ul><ul><li>Statspack has been updated to be “10g aware”. </li></ul>
  42. 42. Time Model Statistics <ul><li>New concept in Oracle 10g. </li></ul><ul><li>Two new views provide a more detailed picture of how Oracle spends time: </li></ul><ul><ul><li>Separates out background and user processes. </li></ul></ul><ul><ul><li>Provides data not previously available, such as how much time was spent in PL/SQL execution. </li></ul></ul><ul><li>Times are in microseconds. </li></ul>
  43. 43. Time Model Statistics <ul><li>SQL> DESCRIBE v$sys_time_model </li></ul><ul><li>Name Null? Type </li></ul><ul><li>---------------------------------------- -------- --------------------------- </li></ul><ul><li>STAT_ID NUMBER </li></ul><ul><li>STAT_NAME VARCHAR2(64) </li></ul><ul><li>VALUE NUMBER </li></ul><ul><li>SQL> DESCRIBE v$sess_time_model </li></ul><ul><li>Name Null? Type </li></ul><ul><li>---------------------------------------- -------- --------------------------- </li></ul><ul><li>SID NUMBER </li></ul><ul><li>STAT_ID NUMBER </li></ul><ul><li>STAT_NAME VARCHAR2(64) </li></ul><ul><li>VALUE NUMBER </li></ul>
  44. 44. Time Model Statistics <ul><li>Some important notes about these statistics: </li></ul><ul><ul><li>Statistics do not include background processes unless “background” appears in the statistic name. </li></ul></ul><ul><ul><li>“DB time” shows elapsed time spent in Oracle calls. (Basically CPU time plus non-idle waits.) </li></ul></ul>
  45. 45. Time Model Statistics Example <ul><li>SQL> SELECT stat_name, value / 1000000 seconds FROM v$sys_time_model </li></ul><ul><li>2 ORDER BY seconds DESC; </li></ul><ul><li>STAT_NAME SECONDS </li></ul><ul><li>------------------------------------------------ ---------- </li></ul><ul><li>DB time 80970.190 </li></ul><ul><li>sql execute elapsed time 75057.271 </li></ul><ul><li>DB CPU 44448.628 </li></ul><ul><li>background elapsed time 29333.160 </li></ul><ul><li>PL/SQL execution elapsed time 8824.538 </li></ul><ul><li>background cpu time 5170.311 </li></ul><ul><li>parse time elapsed 1270.147 </li></ul><ul><li>hard parse elapsed time 838.068 </li></ul><ul><li>PL/SQL compilation elapsed time 176.731 </li></ul><ul><li>sequence load elapsed time 112.334 </li></ul><ul><li>connection management call elapsed time 44.644 </li></ul><ul><li>failed parse elapsed time 11.946 </li></ul><ul><li>hard parse (sharing criteria) elapsed time 5.579 </li></ul><ul><li>hard parse (bind mismatch) elapsed time 4.610 </li></ul><ul><li>failed parse (out of shared memory) elapsed time 0.000 </li></ul><ul><li>Java execution elapsed time 0.000 </li></ul><ul><li>inbound PL/SQL rpc elapsed time 0.000 </li></ul>
  46. 46. Tracing Improvements <ul><li>Enabling extended SQL trace in another session is now more convenient. </li></ul><ul><li>Tracing sessions in a connection pooling or shared server environment is no longer impractical. </li></ul><ul><li>New dbms_monitor package offers these two benefits and more. </li></ul>
  47. 47. Tracing Prior to Oracle 10g <ul><li>Tracing sessions in Oracle 9i and earlier had annoyances: </li></ul><ul><ul><li>dbms_support usually missing or not installed. </li></ul></ul><ul><ul><li>dbms_system.set_ev not officially supported. </li></ul></ul><ul><ul><li>ALTER SESSION SET EVENTS to set 10046 event has a syntax hard (for some of us) to remember. </li></ul></ul>
  48. 48. Easier Tracing in Oracle 10g <ul><li>Control tracing of your own session: </li></ul><ul><li>EXECUTE dbms_monitor.session_trace_enable (waits=>TRUE, binds=>TRUE); </li></ul><ul><li>EXECUTE dbms_monitor.session_trace_disable (); </li></ul><ul><li>Control tracing of another session: </li></ul><ul><li>EXECUTE dbms_monitor.session_trace_enable (session_id=>153, waits=>TRUE); </li></ul><ul><li>EXECUTE dbms_monitor.session_trace_disable (session_id=>153); </li></ul><ul><li>Tracing sessions in Oracle 10g is easier because dbms_monitor is provided and installed in every Oracle 10g database by default. </li></ul>
  49. 49. Tracing Prior to Oracle 10g <ul><li>Straightforward if session being traced uses dedicated server connection. </li></ul><ul><li>Tracing session using shared server architecture leads to multiple trace files that have to be merged manually. </li></ul><ul><li>Tracing an end-user session that does not map to one Oracle session (eg: connection pooling or multiplexing) is not practical. </li></ul>
  50. 50. New Tracing Features in 10g <ul><li>Tracing can be enabled for sessions with a specific client identifier: </li></ul><ul><li>EXECUTE dbms_session.set_identifier ('client identifier'); </li></ul><ul><li>EXECUTE dbms_session.clear_identifier (); </li></ul><ul><li>Tracing can be enabled for sessions with specific service / module / action combination: </li></ul><ul><li>EXECUTE dbms_application_info.set_module ('module name', 'action name'); </li></ul><ul><li>EXECUTE dbms_application_info.set_action ('action name'); </li></ul><ul><li>Trace data split over multiple trace files can be merged into one trace file for TKPROF processing: </li></ul><ul><li>$ trcsess output= [clientid=] [service=] [module=] [action=] [session=] </li></ul>
  51. 51. Connection Pooling Example <ul><li>Application server connection pooling code: </li></ul><ul><li>EXECUTE dbms_session.set_identifier ('session_id from application table'); </li></ul><ul><li>...do the work for this end user session... </li></ul><ul><li>EXECUTE dbms_session.clear_identifier (); </li></ul><ul><li>Trace the end-user session assigned session_id 12345 in the application’s sessions table: </li></ul><ul><li>SQL> EXECUTE dbms_monitor.client_id_trace_enable - </li></ul><ul><li>> (client_id=>'12345', waits=>TRUE, binds=>TRUE); </li></ul><ul><li>Consolidate trace data into one trace file suitable for use by TKPROF: </li></ul><ul><li>$ cd $ORACLE_BASE/admin/$ORACLE_SID/udump </li></ul><ul><li>$ trcsess output=mytracefile.trc clientid=12345 </li></ul>
  52. 52. Twelve Oracle 10g Enhancements <ul><ul><ul><li>More descriptive wait event names </li></ul></ul></ul><ul><ul><ul><li>Wait event classes </li></ul></ul></ul><ul><ul><ul><li>v$event_name new columns </li></ul></ul></ul><ul><ul><ul><li>v$sql / v$sqlarea new columns </li></ul></ul></ul><ul><ul><ul><li>v$session_wait_history </li></ul></ul></ul><ul><ul><ul><li>v$session new columns </li></ul></ul></ul><ul><ul><ul><li>v$event_histogram </li></ul></ul></ul><ul><ul><ul><li>v$system_wait_class / v$session_wait_class </li></ul></ul></ul><ul><ul><ul><li>Active Session History (ASH) </li></ul></ul></ul><ul><ul><ul><li>Automatic Workload Repository (AWR) </li></ul></ul></ul><ul><ul><ul><li>Time model statistics </li></ul></ul></ul><ul><ul><ul><li>Improved session tracing </li></ul></ul></ul>
  53. 53. Wrapping Up <ul><li>Oracle 10g includes many enhancements to the wait event interface that should make performance management using wait event methodologies easier than ever. </li></ul><ul><li>Some are just conveniences: </li></ul><ul><ul><li>More descriptive event names, wait event classes, dbms_monitor.session_trace_enable... </li></ul></ul><ul><li>Some provide data previously unavailable: </li></ul><ul><ul><li>New v$sql columns, time model statistics, v$event_histogram... </li></ul></ul>
  54. 54. White Paper <ul><li>Contains additional detail we didn’t have time to cover today. </li></ul><ul><li>Includes a handy reference list of all Oracle 10g wait events, wait classes, and wait event parameters. </li></ul><ul><li>Download: www.dbspecialists.com/presentations </li></ul>
  55. 55. Contact Information <ul><li>Terry Sutton and Roger Schrag </li></ul><ul><ul><li>Database Specialists, Inc. </li></ul></ul><ul><ul><li>388 Market Street, Suite 400 </li></ul></ul><ul><ul><li>San Francisco, CA 94111 </li></ul></ul><ul><ul><li>Tel: 415/344-0500 </li></ul></ul><ul><ul><li>Toll-free: 888/648-0500 </li></ul></ul><ul><ul><li>www.dbspecialists.com </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul><ul><ul><li>[email_address] </li></ul></ul>

×