6 Copyright © 2006, Oracle. All rights reserved. Using Automatic Workload Repository.
-
Upload
garry-mathews -
Category
Documents
-
view
216 -
download
0
Transcript of 6 Copyright © 2006, Oracle. All rights reserved. Using Automatic Workload Repository.
6Copyright © 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-tuningcomponent
Self-tuningcomponent
…Internal clients
External clientsEM SQL*Plus …
Efficientin-memorystatisticscollection
AWRsnapshotsMMON
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$SYSSTATV$SQL
V$SEGMENT_STATISTICSV$SYS_TIME_MODEL
V$SYSMETRIC_HISTORYV$SYSTEM_WAIT_CLASS
V$OSSTATV$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-memorystatistics
6:00 a.m.7:00 a.m.
8:00 a.m.
Snapshot 1Snapshot 2Snapshot 3
Snapshot 49: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 periodin the past
6-7 Copyright © 2006, Oracle. All rights reserved.
AWR Snapshot Purging Policy
SYSAUX tablespace
sys schema
Snapshot
Snapshot
Snapshot
Snapshot
7days
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
≠
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
Advisorresults
AWR
SQLstatistics
Basestatistics
Metrics ASH
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 snapshotsDROP_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-memorystatistics
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 sendsa request.
User getsa response.
User 1
User 2
User n
Connect Execute Fetch Fetch Fetch Execute
Database time Wall-clock time
6-20 Copyright © 2006, Oracle. All rights reserved.
DBTime-graph and ADDM Methodology
Userconnect
Root node
SQLoptimization
SQLexecution
Undersizedbuffer cache
I/Ocapacity
Databaselocks
Insufficient I/Obandwidth
CPUcapacity
Dimension 1 Dimension 2
Symptoms
Root causes
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 detectedby 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_defaultFROM dba_advisor_def_parametersWHERE 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_tasksWHERE 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');
SQL> @?/rdbms/admin/addmrpt…Enter value for begin_snap: 8Enter 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
Rollingbuffer
Workload repository
1sec
1sec
1sec
Every60 minutes
MMON
MMNL
When 66% full
V$ACTIVE_SESSION_HISTORY
WRH$_ACTIVE_SESSION_HISTORY (partitioned)
No useof SQL
Direct pathinserts
DBA_HIST_ACTIVE_SESSION_HISTORY
1 outof 10
Viewers gounlatched.
6-31 Copyright © 2006, Oracle. All rights reserved.
ASH Sampling: Example
Session1
Wait I/OWait LockWait BlockWait I/OWait I/OWait LockWait I/O
Wait Block
…
…
Sess1 Wait I/OSess1 Wait I/O
Sess1 Wait Block
Session2active
Session3active
Sessionnactive
…
Active Inactivesessions
1sec
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
<<<ACTIVE SESSION HISTORY - PROCESS TRACE DUMP HEADER BEGIN>>>
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
<<<ACTIVE SESSION HISTORY - PROCESS TRACE DUMP HEADER END>>>
<<<ACTIVE SESSION HISTORY - PROCESS TRACE DUMP BEGIN>>>
1090770270,1,1317127,"08-26-2005 01:11:40.505471000", 162, 1, 0, "", 0, 0, 165959219, 2, 0, 4294967295, 0,0,0,,5129,1,11242,86156091,1664,0,0,0,0,64620,0,"oracle@edrsr14p1 (CJQ0)","","","",1090770270,1,1317116,"08-26-2005 01:11:29.505471000", 142,20,24, "0hbv80w9ypy0n",0,3304045827, 3427055676, 1,3,4294967291, 0,0,0,,8751, 3,2486, 1421975091,24975,1413697536,1,0,620,0,17258348159868772889,"emagent@edrsr14p1 (TNS V1-V3)","emagent@edrsr14p1 (TNS V1-V3)","",""
…
<<<ACTIVE SESSION HISTORY - PROCESS TRACE DUMP END>>>
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 = '';
SQL> @?/rdbms/admin/ashrpti
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