6 Copyright © 2006, Oracle. All rights reserved. Using Automatic Workload Repository
6-2 Copyright © 2006, Oracle. All rights reserved. Objectives After completing this lesson, you should be able to do the following: Create and manage Automatic Workload Repository (AWR) snapshots Generate AWR reports Create snapshot sets and compare periods Generate ADDM reports Generate ASH reports
6-3 Copyright © 2006, Oracle. All rights reserved. Automatic Workload Repository: Overview SGA V$DBA_* ADDM Self-tuning component … Internal clients External clients EMSQL*Plus … Efficient in-memory statistics collection AWR snapshots MMON
6-4 Copyright © 2006, Oracle. All rights reserved. Automatic Workload Repository Data Base statistics: –SQL and optimizer statistics –OS statistics –Wait classes –Time statistics Metrics Active Session History Advisor results Snapshot statistics Database feature usage V$SYSSTAT V$SQL V$SEGMENT_STATISTICS V$SYS_TIME_MODEL V$SYSMETRIC_HISTORY V$SYSTEM_WAIT_CLASS V$OSSTAT V$ACTIVE_SESSION_HISTORY DBA_ADVISOR_* DBA_HIST_* DBA_FEATURE_* DBA_HIGH_WATER_MARK_* DBA_TAB_STATS_HISTORY
6-5 Copyright © 2006, Oracle. All rights reserved. Workload Repository SYSAUX SGA In-memory statistics 6:00 a.m. 7:00 a.m. 8:00 a.m. Snapshot 1 Snapshot 2 Snapshot 3 Snapshot 4 9:00 a.m. 9:30 a.m. ADDM finds top problems. MMON
6-6 Copyright © 2006, Oracle. All rights reserved. AWR Snapshot Sets DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE ( - start_snap_id IN NUMBER, end_snap_id IN NUMBER, baseline_name IN VARCHAR2); Relevant period in the past
6-7 Copyright © 2006, Oracle. All rights reserved. AWR Snapshot Purging Policy SYSAUX tablespace sys schema Snapshot 7 days Snapshot MMON Every night 60 min
6-8 Copyright © 2006, Oracle. All rights reserved. AWR Snapshot Settings DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS ( - retention IN NUMBER DEFAULT NULL, interval IN NUMBER DEFAULT NULL, topnsql IN NUMBER DEFAULT NULL);
6-9 Copyright © 2006, Oracle. All rights reserved. Database Control and AWR
6-10 Copyright © 2006, Oracle. All rights reserved. Generating AWR Reports in EM
6-11 Copyright © 2006, Oracle. All rights reserved. Generating AWR Reports in SQL*Plus
6-12 Copyright © 2006, Oracle. All rights reserved. Snapshot Sets and Period Comparisons
6-13 Copyright © 2006, Oracle. All rights reserved. Compare Periods: Benefits DBA ≠ ≠
6-14 Copyright © 2006, Oracle. All rights reserved. Compare Periods: General
6-15 Copyright © 2006, Oracle. All rights reserved. Compare Periods: Report
6-16 Copyright © 2006, Oracle. All rights reserved. AWR Data Advisor results AWR SQL statistics Base statistics MetricsASH
6-17 Copyright © 2006, Oracle. All rights reserved. DBMS_WORKLOAD_REPOSITORY Package Procedure to modify the snapshot settings MODIFY_SNAPSHOT_SETTINGS Procedure to drop a single AWR baseline DROP_BASELINE Procedure to create a single AWR baseline CREATE_BASELINE Procedure to drop a range of snapshots DROP_SNAPSHOT_RANGE Procedure to create a manual snapshot immediately CREATE_SNAPSHOT DescriptionProcedure Name
6-18 Copyright © 2006, Oracle. All rights reserved. ADDM Performance Monitoring Snapshots ADDM In-memory statistics AWR SGA 60 minutes ADDM results MMON
6-19 Copyright © 2006, Oracle. All rights reserved. ADDM and Database Time Wide area network Application server Local area network Oracle database User sends a request. User gets a response. User 1 User 2 User n Connect Execute Fetch Execute Database time Wall-clock time
6-20 Copyright © 2006, Oracle. All rights reserved. DBTime-graph and ADDM Methodology User connect Root node SQL optimization SQL execution Undersized buffer cache I/O capacity Database locks Insufficient I/O bandwidth CPU capacity Dimension 1 Dimension 2 Symptoms Root causes
6-21 Copyright © 2006, Oracle. All rights reserved. Notes only slide
6-22 Copyright © 2006, Oracle. All rights reserved. Top Performance Issues Detected Excessive logon/logoff Memory undersizing Hot blocks and objects w/SQL RAC service issues Locks and ITL contention Checkpointing causes PL/SQL, Java time Streams, AQ, and RMAN Top SQL I/O issues Parsing Configuration issues Application usage Not detected by Statspack ADDM identifies top issues.
6-23 Copyright © 2006, Oracle. All rights reserved. Database Control and ADDM Findings
6-24 Copyright © 2006, Oracle. All rights reserved. ADDM Analysis Results 1 2 3
6-25 Copyright © 2006, Oracle. All rights reserved. ADDM Recommendations
6-26 Copyright © 2006, Oracle. All rights reserved. Database Control and ADDM Task
6-27 Copyright © 2006, Oracle. All rights reserved. Changing ADDM Attributes 1.Ensure that STATISTICS_LEVEL is set to TYPICAL or ALL. 2.ADDM analysis of I/O performance depends on the expected speed of the I/O subsystem: a.Measure your I/O subsystem speed. b.Set the expected speed. SQL> exec DBMS_ADVISOR.SET_DEFAULT_TASK_PARAMETER(- 'ADDM', 'DBIO_EXPECTED', 8000); SELECT parameter_value, is_default FROM dba_advisor_def_parameters WHERE advisor_name = 'ADDM' AND parameter_name = 'DBIO_EXPECTED';
6-28 Copyright © 2006, Oracle. All rights reserved. Retrieving ADDM Reports by Using SQL 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'); … Enter value for begin_snap: 8 Enter value for end_snap: 10 … Enter value for report_name: Generating the ADDM report for this analysis...
6-29 Copyright © 2006, Oracle. All rights reserved. Active Session History: Overview Stores the history of database time Samples session activity in the system including: –SQL identifier of a SQL statement –Object number, file number, and block number –Wait event identifier and parameters –Session identifier and session serial number –Module and action name –Client identifier of the session –Service hash identifier –Blocking session Is always on for first fault analysis No need to replay the workload
6-30 Copyright © 2006, Oracle. All rights reserved. Active Session History: Mechanics SGA Statistics V$SESSION ASH Recent history Rolling buffer Workload repository 1sec Every 60 minutes MMON MMNL When 66% full V$ACTIVE_SESSION_HISTORY WRH$_ACTIVE_SESSION_HISTORY (partitioned) No use of SQL Direct path inserts DBA_HIST_ACTIVE_SESSION_HISTORY 1 out of 10 Viewers go unlatched.
6-31 Copyright © 2006, Oracle. All rights reserved. ASH Sampling: Example Session1 Wait I/O Wait Lock Wait Block Wait I/O Wait Lock Wait I/O Wait Block … … Sess1 Wait I/O Sess1 Wait Block Session2 active Session3 active Session n active … Active Inactive sessions 1sec ASH … V$ACTIVE_SESSION_HISTORY Time
6-32 Copyright © 2006, Oracle. All rights reserved. Accessing ASH Data Dump to trace file V$ACTIVE_SESSION_HISTORY DBA_HIST_ACTIVE_SESS_HISTORY ASH report EM Diagnostic Pack performance pages ADDM
6-33 Copyright © 2006, Oracle. All rights reserved. Dump ASH to File The generated file contains ASH samples for the last number of minutes specified: SQL> oradebug setmypid SQL> oradebug dump ashdump 10 >> DBID, INSTANCE_NUMBER, SAMPLE_ID, SAMPLE_TIME, SESSION_ID, SESSION_SERIAL#, USER_ID, SQL_ID, SQL_CHILD_NUMBER, SQL_PLAN_HASH_VALUE, SERVICE_HASH, SESSION_TYPE, SQL_OPCODE, BLOCKING_SESSION, BLOCKING_SESSION_SERIAL# QC_SESSION_ID, QC_INSTANCE_ID, XID, CURRENT_OBJ#, CURRENT_FILE#, CURRENT_BLOCK#, EVENT_ID, SEQ#, P1, P2, P3, WAIT_TIME, TIME_WAITED, FORCE_MATCHING_SIGNATURE, PROGRAM, MODULE, ACTION, CLIENT_ID >> ,1, ," :11: ", 162, 1, 0, "", 0, 0, , 2, 0, , (CJQ0)","","","", ,1, ," :11: ", 142,20,24, "0hbv80w9ypy0n",0, , , 1,3, , 0,0,0,,8751, 3,2486, (TNS V1- (TNS V1-V3)","","" … >>
6-34 Copyright © 2006, Oracle. All rights reserved. Sifting the ASHes GROUP BY and COUNT –Proxy for nonidle elapsed time –Proportions of actual time spent Can analyze any time slice Example: Returns most active SQL in the past minute SELECT sql_id, count(*), round(count(*)/sum(count(*)) over (), 2) pctload FROM v$active_session_history WHERE sample_time > sysdate -1/24/60 and session_type <> 'BACKGROUND' GROUP BY sql_id ORDER BY count(*) desc;
6-35 Copyright © 2006, Oracle. All rights reserved. Generating ASH Reports
6-36 Copyright © 2006, Oracle. All rights reserved. ASH Report Script SQL> define dbid = ''; SQL> define inst_num = ''; SQL> define report_type = 'html'; SQL> define begin_time = '09:00'; SQL> define duration = 480; SQL> define report_name = '/tmp/sql_ashrpt.txt'; SQL> define slot_width = ''; SQL> define target_session_id = ''; SQL> define target_sql_id = 'abcdefghij123'; SQL> define target_wait_class = ''; SQL> define target_service_hash = ''; SQL> define target_module_name = ''; SQL> define target_action_name = ''; SQL> define target_client_id = '';
6-37 Copyright © 2006, Oracle. All rights reserved. ASH Report: General Section V$ACTIVE_SESSION_HISTORY DBA_HIST_ACTIVE_SESSION_HISTORY
6-38 Copyright © 2006, Oracle. All rights reserved. ASH Report Structure
6-39 Copyright © 2006, Oracle. All rights reserved. ASH Report: Activity Over Time
6-40 Copyright © 2006, Oracle. All rights reserved. Practice Overview: Use AWR-Based Tools This practice covers the following topics: Generate an AWR report Create a preserved set on snapshots Generate an ADDM report Generate an ASH Report
6-41 Copyright © 2006, Oracle. All rights reserved. Summary In this lesson, you should have learned how to: Create and manage AWR snapshots Generate AWR reports Create snapshot sets and compare periods Generate ADDM reports Generate ASH reports
6-42 Copyright © 2006, Oracle. All rights reserved.