Sei sulla pagina 1di 10

Automatic Workload Repository

Pradeep Kumar

Wissen MATTEL Internal

Automatic Workload Repository


The Automatic Workload Repository (AWR) collects, processes, and maintains performance statistics for problem detection and selftuning purposes. The gathered data can be displayed in both reports and views. AWR automatically generates snapshots of the performance data once every hour and collects the statistics in the workload repository. You can also manually create snapshots, but this is usually not necessary. The data in the snapshot interval is then analyzed by the Automatic Database Diagnostic Monitor (ADDM).

Wissen MATTEL Internal

AWR Space Requirements


The space consumed by the Automatic Workload Repository is determined by several factors: Number of active sessions in the system at any given time Snapshot interval
The snapshot interval determines the frequency at which snapshots are captured.

Historical data retention period


The retention period determines how long this data is retained before being purged
By default, the snapshots are captured once in every hour and are retained in the database for 7 days. With these default settings, a typical system with an average of 10 concurrent active sessions can require approximately 200 to 300 MB of space for its AWR data.

Wissen MATTEL Internal

AWR Setup
The STATISTICS_LEVEL initialization parameter must be set to the TYPICAL or ALL to enable the Automatic Workload Repository. If the value is set to BASIC, you can manually capture AWR statistics using procedures in the DBMS_WORKLOAD_REPOSITORY package. You can manually create snapshots with the CREATE_SNAPSHOT procedure . BEGIN DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT (); END; / You can drop a range of snapshots using the DROP_SNAPSHOT_RANGE procedure. BEGIN DBMS_WORKLOAD_REPOSITORY.DROP_SNAPSHOT_RANGE (low_snap_id => 22, high_snap_id => 32, dbid => 3310949047); END; /

Wissen MATTEL Internal

AWR Data Collection


Modifying Snapshot Settings
BEGIN DBMS_WORKLOAD_REPOSITORY.MODIFY_SNAPSHOT_SETTINGS( retention => 43200, interval => 30, dbid => 3310949047); END; /

Workload Repository Reports


The awrrpt.sql SQL script generates an HTML or text report that displays statistics for a range of snapshot Ids.
To run an AWR report, a user must be granted the DBA role

$ORACLE_HOME/rdbms/admin/awrrpt.sql is the location of the file.

Wissen MATTEL Internal

AWR Generating Report


Running the awrrpt.sql Report
To generate a text report for a range of snapshot Ids, run the awrrpt.sql script at the SQL prompt: @$ORACLE_HOME/rdbms/admin/awrrpt.sql First, you need to specify whether you want an HTML or a text report. Enter value for report_type: text Specify the number days for which you want to list snapshot Ids. Enter value for num_days: 2 After the list displays, you are prompted for the beginning and ending snapshot Id for the workload repository report. Enter value for begin_snap: 150 Enter value for end_snap: 160 Next, accept the default report name or enter a report name. The default name is accepted in the following example: Enter value for report_name: Using the report name awrrpt_1_150_160 The workload repository report is generated.

Wissen MATTEL Internal

AWR Additional Info


awrrpt.sql internally calls some more sql files such as awrinput.sql,awrinpnm.sql and awrrpti.sql. The following queries are used by awrrpt.sql.
select distinct (case when cd.dbid = wr.dbid and cd.name = wr.db_name and ci.instance_number = wr.instance_number and ci.instance_name = wr.instance_name then '* ' else ' ' end) || wr.dbid dbbid , wr.instance_number instt_num , wr.db_name dbb_name , wr.instance_name instt_name , wr.host_name host from dba_hist_database_instance wr, v$database cd, v$instance ci;

Wissen MATTEL Internal

AWR Additional Info


select to_char(s.startup_time,'dd Mon "at" HH24:mi:ss') instart_fmt , di.instance_name inst_name , di.db_name db_name , s.snap_id snap_id , to_char(s.end_interval_time,'dd Mon YYYY HH24:mi') snapdat , s.snap_level lvl from dba_hist_snapshot s , dba_hist_database_instance di where s.dbid = :dbid and di.dbid = :dbid and s.instance_number = :inst_num and di.instance_number = :inst_num and di.dbid = s.dbid and di.instance_number = s.instance_number and di.startup_time = s.startup_time and s.end_interval_time >= decode( &num_days , 0 , to_date('31-JAN-9999','DD-MON-YYYY') , 3.14, s.end_interval_time , to_date(:max_snap_time,'dd/mm/yyyy') - (&num_days-1)) order by db_name, instance_name, snap_id;

Wissen MATTEL Internal

AWR Additional Info


bsnapt dba_hist_snapshot.end_interval_time%type; bstart dba_hist_snapshot.startup_time%type; bsnapt dba_hist_snapshot.end_interval_time%type; bstart dba_hist_snapshot.startup_time%type; esnapt dba_hist_snapshot.end_interval_time%type; estart dba_hist_snapshot.startup_time%type;

Wissen MATTEL Internal

Q&A

Wissen MATTEL Internal

Potrebbero piacerti anche