Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Performance Tuning With Oracle ASH and AWR. Part 1 How And What

20,223 views

Published on

Published in: Technology
  • Be the first to comment

Performance Tuning With Oracle ASH and AWR. Part 1 How And What

  1. 1. Part 1 : What, When and How Virtathon 7/2011 Uday Moogala Vlado Barun
  2. 2. <ul><li>Uday Moogala </li></ul><ul><ul><li>Sr. Principal Engineer with Oracle Apps Development </li></ul></ul><ul><ul><li>15 years in the Oracle Database arena </li></ul></ul><ul><li>Vlado Barun, M.Sc. </li></ul><ul><ul><li>Sr. Principal Performance Engineer with Oracle Cloud Services </li></ul></ul><ul><ul><li>OCP, OCE SQL, MCP </li></ul></ul><ul><ul><li>15 years in the Database Arena (Oracle - 10 years) </li></ul></ul>Who we are
  3. 3. <ul><li>All the views expressed in this presentation are </li></ul><ul><li>the opinion of the authors and do not </li></ul><ul><li>necessarily reflect the views of Oracle America, </li></ul><ul><li>Inc. </li></ul><ul><li>The queries are provided &quot;as is&quot;, without </li></ul><ul><li>warranty of any kind, expressed or implied. </li></ul>Disclaimer
  4. 4. <ul><li>How to approach a SQL performance issue </li></ul><ul><li>What diagnostic data to gather </li></ul><ul><li>Generating and interpreting </li></ul><ul><ul><li>AWR Report </li></ul></ul><ul><ul><li>ASH Reports </li></ul></ul><ul><ul><li>SQL Execution Plans </li></ul></ul><ul><ul><li>Real-Time SQL Monitoring Reports </li></ul></ul>Agenda
  5. 5. In order to know what to fix, we need to be able to see what’s broken! - Dan Roam
  6. 6. What Identify (app is slow) Quantify (takes 1m) Timeline (in peak hours) Component (MT or DB or N/W) Flow chart Root Cause (Stats not updated) AWR/ASH, Trace, Apps Logs/Tables, OS/IO stats etc SQL/Object Stats, Execution Plans, etc Initial Data collec-tion How Much When Where How Why Analyze Additional Data collec-tion Understanding the issue…
  7. 7. Non-DB Time DB Time Getting to know the System…
  8. 8. An example… I/O On CPU I/O On CPU Browse Books Read Reviews For One Book Add to Cart Checkout TIME = time spent in database = user/network/app tier time
  9. 9. = time spent in database SQL Trace (Microsecond level) Application Logging (custom level) Gathering Performance Data… (SQL Trace, ASH) 21 ASH Samples 3 ASH Samples in AWR Browse Books Read Reviews For One Book Add to Cart Checkout TIME v$active_session_history (1 second intervals) dba_hist_active_sess_history (10 second intervals)
  10. 10. Automatic Workload Repository (AWR) <ul><li>Collects database performance statistics </li></ul><ul><ul><li>- Objects (access and usage statistics) </li></ul></ul><ul><ul><li>SQL Statement statistics </li></ul></ul><ul><ul><li>Wait events statistics </li></ul></ul><ul><ul><li>System statistics </li></ul></ul><ul><ul><li>ASH Statistics ( DBA_HIST_ACTIVE_SESS_HISTORY ) </li></ul></ul><ul><ul><li>Time Model Statistics based on time usage for activities </li></ul></ul><ul><ul><li>Every 1 hr by default </li></ul></ul><ul><li>Stored in DBA_HIST% views </li></ul><ul><li>How to access? </li></ul><ul><ul><li>$ORACLE_HOME/rdbms/admin/awrrpt.sql </li></ul></ul><ul><ul><li>OEM </li></ul></ul><ul><ul><li>Other tools </li></ul></ul><ul><li>Sample output </li></ul>
  11. 11. Active Session History (ASH) <ul><li>Samples the current state of all active sessions </li></ul><ul><ul><li>- 1 second samples </li></ul></ul><ul><ul><li>- Stores various attributes (dimensions) of a session </li></ul></ul><ul><li>Stored in </li></ul><ul><ul><li>V$ACTIVE_SESSION_HISTORY </li></ul></ul><ul><ul><ul><li>1-second sampling rate </li></ul></ul></ul><ul><ul><li>DBA_HIST_ACTIVE_SESS_HISTORY </li></ul></ul><ul><ul><ul><li>Sub-sampling to disk into AWR Snapshot </li></ul></ul></ul><ul><ul><ul><li>1-in-10 samples </li></ul></ul></ul><ul><li>How to access? </li></ul><ul><ul><li>$ORACLE_HOME/rdbms/admin/ashrpt.sql, ashrpti.sql </li></ul></ul><ul><ul><li>OEM </li></ul></ul><ul><ul><li>Other tools </li></ul></ul><ul><li>Sample output </li></ul>
  12. 12. Active Session History (ASH) - Dimensions When SAMPLE_ID SAMPLE_TIME Session SESSION_ID SESSION_SERIAL# SESSION_TYPE SESSION_STATE USER_ID QC_INSTANCE_ID QC_SESSION_ID QC_SESSION_SERIAL# CLIENT_ID IN and IS columns SQL SQL_ID IS_SQLID_CURRENT SQL_CHILD_NUMBER SQL_OPCODE SQL_OPNAME TOP_LEVEL_SQL_ID TOP_LEVEL_SQL_OPCODE SQL_EXEC_ID SQL_EXEC_START SQL_PLAN_HASH_VALUE SQL_PLAN_OPTIONS Row Source SQL_PLAN_LINE_ID SQL_PLAN_OPERATION Waits EVENT EVENT_ID EVENT# SEQ# P1TEXT P1 P2TEXT P2 P3TEXT P3 WAIT_CLASS WAIT_CLASS_ID WAIT_TIME TIME_WAITED CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW# Blocking Session BLOCKING_SESSION_STATUS BLOCKING_SESSION BLOCKING_SESSION_SERIAL# BLOCKING_INST_ID BLOCKING_HANGCHAIN_INFO Object CURRENT_OBJ# CURRENT_FILE# CURRENT_BLOCK# CURRENT_ROW# Application SERVICE_HASH PROGRAM MODULE ACTION MACHINE Statistics TM_DELTA_TIME TM_DELTA_CPU_TIME TM_DELTA_DB_TIME DELTA_TIME DELTA_READ_IO_REQUESTS DELTA_WRITE_IO_REQUESTS DELTA_READ_IO_BYTES DELTA_WRITE_IO_BYTES DELTA_INTERCONNECT_IO_BYTES PGA_ALLOCATED TEMP_SPACE_ALLOCATED
  13. 13. SQL Execution Plans <ul><li>DBMS_XPLAIN. DISPLAY_CURSOR </li></ul><ul><ul><li>Plan is from memory </li></ul></ul><ul><ul><li>Predicates and outline data </li></ul></ul><ul><ul><li>most useful when ‘statistics_level’ set to ALL or with gather_plan_statistics hint </li></ul></ul><ul><ul><li>Sample output </li></ul></ul><ul><li>DBMS_XPLAIN. DISPLAY_AWR </li></ul><ul><ul><li>Plan is from AWR (DBA_HIST% views) </li></ul></ul><ul><ul><li>Runtime (actual) stats are not displayed </li></ul></ul><ul><ul><li>Sample output </li></ul></ul><ul><li>Sample output </li></ul>
  14. 14. select * from table(dbms_xplan.display_cursor('&SQL_ID',null,'ALLSTATS LAST')); SQL_ID 0s5pdsggxtc54, child number 0 ------------------------------------- Plan hash value: 2832870632 ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 152K(100)| | | 1 | SORT AGGREGATE | | 1 | 2 | | | |* 2 | TABLE ACCESS FULL| TAB_A | 21M| 41M| 152K (5)| 00:00:03 | ---------------------------------------------------------------------------- Predicate Information (identified by operation id): --------------------------------------------------- 2 - filter(&quot;COSTED_FLAG&quot; IS NULL) Note ----- - Warning: basic plan statistics not available. These are only collected when: * hint 'gather_plan_statistics' is used for the statement or * parameter 'statistics_level' is set to 'ALL', at session or system level Display_Cursor Estimates with Statistics_level = Typical SQL_ID 0s5pdsggxtc54, child number 1 ------------------------------------- Plan hash value: 2832870632 -------------------------------------------------------------------------------------- | Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | -------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 1 | | 1 |00:00:01.73 | 435K| | 1 | SORT AGGREGATE | | 1 | 1 | 1 |00:00:01.73 | 435K| |* 2 | TABLE ACCESS FULL| TAB_A | 1 | 1351K| 2001K|00:00:01.64 | 435K| -------------------------------------------------------------------------------------- Actual runtime stats with Statistics_level = ALL or with gather_plan_statistics hint
  15. 15. Display_AWR SQL_ID 0s5pdsggxtc54 -------------------- ---------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ---------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | | | 22217 (100)| | | 1 | SORT AGGREGATE | | 1 | 2 | | | | 2 | TABLE ACCESS FULL| TAB_A | 1351K| 2639K| 22217 (1)| 00:04:27 | ----------------------------------------------------------------------------
  16. 16. Real-Time SQL Monitoring <ul><li>Monitors SQLs while they are running </li></ul><ul><li>Automatically monitors parallel SQLs and SQLs taking more than 5 CPU seconds </li></ul><ul><ul><li>Plan is from memory </li></ul></ul><ul><ul><li>Predicates </li></ul></ul><ul><ul><li>CPU and Elapsed Time </li></ul></ul><ul><ul><li>No. of reads and writes </li></ul></ul><ul><ul><li>Waits </li></ul></ul><ul><li>Stored in V$SQL_MONITOR and V$SQL_PLAN_MONITOR views </li></ul><ul><li>How to access? </li></ul><ul><ul><li>DBMS_SQLTUNE.REPORT_SQL_MONITOR </li></ul></ul><ul><ul><li>Enterprise Manager </li></ul></ul><ul><li>Sample output </li></ul>
  17. 17. Summary <ul><li>AWR Report </li></ul><ul><ul><li>Identified SQL issue </li></ul></ul><ul><ul><li>Get report snapshots as close as possible to the issue </li></ul></ul><ul><li>ASH Report </li></ul><ul><ul><li>- At system level to identify the session </li></ul></ul><ul><ul><li>At session level to identify the SQL </li></ul></ul><ul><ul><li>At SQL level to identify the row source, object, and wait events </li></ul></ul><ul><ul><li>Analyze samples taken during problematic SQL execution </li></ul></ul><ul><li>SQL Execution Plans </li></ul><ul><ul><li>Dbms_Xplain.Display_Cursor </li></ul></ul><ul><ul><li>Dbms_Xplain.Display_AWR </li></ul></ul><ul><ul><li>set STATISTICS_LEVEL to ‘ ALL ’ or put GATHER_PLAN_STATISTICS hint </li></ul></ul><ul><li>Real-Time SQL Monitoring Report </li></ul><ul><ul><li>To monitor the long running or parallel SQL </li></ul></ul><ul><ul><li>Take several reports and analyze the issue </li></ul></ul>
  18. 18. <ul><li>SQL Tuning </li></ul><ul><ul><li>Trace files </li></ul></ul><ul><ul><li>SQLT output (MOS Doc: 215187.1) </li></ul></ul><ul><ul><li>Trace Analyzer (MOS Doc : 224270.1) </li></ul></ul><ul><ul><li>AWR Report (MOS Doc : 748642.1) </li></ul></ul><ul><ul><li>AWR SQL Report (awrsqrpt.sql) </li></ul></ul><ul><ul><li>11g Real-Time SQL Monitoring </li></ul></ul><ul><ul><li>SQL Tuning Advisor </li></ul></ul><ul><li>PL/SQL Tuning </li></ul><ul><ul><li>Product logs </li></ul></ul><ul><ul><li>PL/SQL Profiler (MOS Doc : 808005.1) </li></ul></ul><ul><li>Forms Tuning </li></ul><ul><ul><li>Forms Tracing (MOS Doc : 373548.1) </li></ul></ul><ul><ul><li>Generic MOS Doc : 438652.1 </li></ul></ul><ul><li>Reports Tracing </li></ul><ul><ul><li>MOS Doc: 111311.1 </li></ul></ul><ul><li>Database Tuning </li></ul><ul><ul><li>AWR Report (MOS Doc : 748642.1) </li></ul></ul><ul><ul><li>ADDM report (MOS Doc : 250655.1) </li></ul></ul><ul><ul><li>Active Session History (ASH) Report </li></ul></ul><ul><ul><li>LTOM output (MOS Doc : 352363.1) </li></ul></ul><ul><li>Middletier Tuning </li></ul><ul><ul><li>JVM Logs </li></ul></ul><ul><ul><li>Third Party Tools </li></ul></ul><ul><li>OS </li></ul><ul><ul><li>OSWatcher (MOS Doc : 301137.1) </li></ul></ul>Reference
  19. 19. Reference <ul><li>Performance Fundamentals for Oracle Database 10g and 11g by Graham Wood and John Beresniewicz </li></ul><ul><li>(http://www.oracle.com/technetwork/database/focus-areas/manageability/db-perf-tuning-ow08-131582.pdf ) </li></ul><ul><li>ASH - Active Session History </li></ul><ul><li>(https://sites.google.com/site/embtdbo/wait-event-documentation/ash---active-session-history) </li></ul>
  20. 20. Q & A

×