Sei sulla pagina 1di 40

6

Using Automatic Workload Repository

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-2 Copyright © 2006, Oracle. All rights reserved.


Automatic Workload Repository: Overview

External clients
EM SQL*Plus …

SGA
Efficient V$ DBA_*
in-memory AWR
statistics snapshots
collection MMON

Self-tuning … Self-tuning
ADDM
Internal clients component component

6-3 Copyright © 2006, Oracle. All rights reserved.


Automatic Workload Repository Data

• Base statistics: V$SYSSTAT


– SQL and optimizer V$SQL
statistics V$SEGMENT_STATISTICS
V$SYS_TIME_MODEL
– OS statistics V$SYSMETRIC_HISTORY
– Wait classes V$SYSTEM_WAIT_CLASS
– Time statistics V$OSSTAT
V$ACTIVE_SESSION_HISTORY
• Metrics
• Active Session History
DBA_ADVISOR_*
• Advisor results DBA_HIST_*
• Snapshot statistics DBA_FEATURE_*
DBA_HIGH_WATER_MARK_*
• Database feature usage
DBA_TAB_STATS_HISTORY

6-4 Copyright © 2006, Oracle. All rights reserved.


Workload Repository

ADDM finds
MMON top problems.

SYSAUX
SGA
6:00 a.m.
Snapshot 1
In-memory 7:00 a.m.
Snapshot 2
statistics 8:00 a.m. Snapshot 3
9:00 a.m.
Snapshot 4

9:30 a.m.

6-5 Copyright © 2006, Oracle. All rights reserved.


AWR Snapshot Sets

Relevant period
in the past

DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE ( -
start_snap_id IN NUMBER ,
end_snap_id IN NUMBER ,
baseline_name IN VARCHAR2);

6-6 Copyright © 2006, Oracle. All rights reserved.


AWR Snapshot Purging Policy

SYSAUX tablespace

sys schema
60 min
Snapshot
7 Snapshot
MMON
days Snapshot
Snapshot Every night
Snapshot

6-7 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-8 Copyright © 2006, Oracle. All rights reserved.


Database Control and AWR

6-9 Copyright © 2006, Oracle. All rights reserved.


Generating AWR Reports in EM

6-10 Copyright © 2006, Oracle. All rights reserved.


Generating AWR Reports in SQL*Plus

6-11 Copyright © 2006, Oracle. All rights reserved.


Snapshot Sets and Period Comparisons

6-12 Copyright © 2006, Oracle. All rights reserved.


Compare Periods: Benefits

DBA

DBA

6-13 Copyright © 2006, Oracle. All rights reserved.


Compare Periods: General

6-14 Copyright © 2006, Oracle. All rights reserved.


Compare Periods: Report

6-15 Copyright © 2006, Oracle. All rights reserved.


AWR Data

Base SQL Advisor


statistics statistics results

Metrics ASH

AWR

6-16 Copyright © 2006, Oracle. All rights reserved.


DBMS_WORKLOAD_REPOSITORY Package

Procedure Name Description

CREATE_SNAPSHOT Procedure to create a manual snapshot


immediately

DROP_SNAPSHOT_RANGE Procedure to drop a range of snapshots

CREATE_BASELINE Procedure to create a single AWR


baseline

DROP_BASELINE Procedure to drop a single AWR


baseline

MODIFY_SNAPSHOT_SETTINGS Procedure to modify the snapshot


settings

6-17 Copyright © 2006, Oracle. All rights reserved.


ADDM Performance Monitoring

60 minutes
MMON

In-memory
statistics
Snapshots
SGA

ADDM

AWR

ADDM results

6-18 Copyright © 2006, Oracle. All rights reserved.


ADDM and Database Time
User sends User gets
a request. a response.

Wide area network

Application server

Local area network

Oracle database

Database time Wall-clock time

Connect Execute Fetch Fetch Fetch Execute


User 1

User 2

User n

6-19 Copyright © 2006, Oracle. All rights reserved.


DBTime-graph and ADDM Methodology

Root node

Symptoms

User SQL SQL CPU I/O Database


connect optimization execution capacity capacity locks

Root causes

Undersized Insufficient I/O


buffer cache bandwidth
Dimension 1 Dimension 2

6-20 Copyright © 2006, Oracle. All rights reserved.


Top Performance Issues Detected

Excessive logon/logoff
Memory undersizing
Hot blocks and objects w/SQL
Not detected
by Statspack RAC service issues
Locks and ITL contention
Checkpointing causes
PL/SQL, Java time
Streams, AQ, and RMAN
Top SQL
I/O issues ADDM
Parsing identifies
Configuration issues top issues.

Application usage

6-22 Copyright © 2006, Oracle. All rights reserved.


Database Control and ADDM Findings

6-23 Copyright © 2006, Oracle. All rights reserved.


ADDM Analysis Results

6-24 Copyright © 2006, Oracle. All rights reserved.


ADDM Recommendations

6-25 Copyright © 2006, Oracle. All rights reserved.


Database Control and ADDM Task

6-26 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-27 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');

SQL> @?/rdbms/admin/addmrpt

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-28 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-29 Copyright © 2006, Oracle. All rights reserved.


Active Session History: Mechanics
Viewers go
unlatched.
V$ACTIVE_SESSION_HISTORY

Statistics
1sec

ASH Direct path 1sec


Rolling
inserts
No use 1sec buffer
of SQL
V$SESSION Every
Recent history
60 minutes
1 out
MMON of 10
SGA

MMNL
Workload repository
When 66% full

WRH$_ACTIVE_SESSION_HISTORY (partitioned)
DBA_HIST_ACTIVE_SESSION_HISTORY

6-30 Copyright © 2006, Oracle. All rights reserved.


ASH Sampling: Example

Session1 V$ACTIVE_SESSION_HISTORY

Wait I/O Session2


Wait Lock active
1sec Wait Block Sess1 Wait I/O
Wait I/O Sess1 Wait I/O
Sess1 Wait Block Session3
Wait I/O
… active
Wait Lock
1sec
Wait I/O ASH …

Wait Block Sessionn
… active
Time
Active Inactive
sessions

6-31 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-32 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-33 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-34 Copyright © 2006, Oracle. All rights reserved.


Generating ASH Reports

6-35 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-36 Copyright © 2006, Oracle. All rights reserved.


ASH Report: General Section

V$ACTIVE_SESSION_HISTORY
DBA_HIST_ACTIVE_SESSION_HISTORY

6-37 Copyright © 2006, Oracle. All rights reserved.


ASH Report Structure

6-38 Copyright © 2006, Oracle. All rights reserved.


ASH Report: Activity Over Time

6-39 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-40 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-41 Copyright © 2006, Oracle. All rights reserved.

Potrebbero piacerti anche