Friday, July 8, 2016

dbms_workload_repository, modify_snapshot_settings : AWR report

How do we modify the snapshot time and retention to store snapshots # 
when ever snapshot is created, MMON will load the in the sysaux tablespace, using following query you can see what are the minimum and max snapshots available on database 

sql> select min(snap_id),MAX(snap_id) from WRH$_ACTIVE_SESSION_HISTORY;
MIN(SNAP_ID) MAX(SNAP_ID)
------------ ------------
  27                         54

we can verify snapshot interval and retention time on sysaux  using  Data dictionary view "dba_hist_wr_control"

sql> select dbid from v$database;
sql>set linesize 100
sql>column SNAP_INTERVAL format a30
sql>column RETENTION format a30
sql>select * from dba_hist_wr_control;
 DBID          SNAP_INTERVAL          RETENTION       TOPNSQL CON_ID
---------- ------------------------------ ------------------------------ ---------- ----------
1854508752 +00000 00:30:00.0   +00030 00:00:00.0  DEFAULT      0

using above query, we can confirm, snap_interval is 30 minutes, indicated database generates snapshot for every 15 minutes and retention is 30 days i.e for every 30 days old snapshots are purged automatically 

we can modify snapshot Interval using package "dbms_workload_repository"
-- Changing snapshot interval to 15 minutes:
-- Note - retention: 43,200 = 30 days # in minutes 
sql> exec dbms_workload_repository.modify_snapshot_settings(retention=>43200, interval=>15, dbid=>1854508752);

Validate changes using following Query 
sql> select dbid from v$database;
sql>set linesize 100
sql>column SNAP_INTERVAL format a30
sql>column RETENTION format a30
sql>select * from dba_hist_wr_control;

create snapshot manually using dbms_world_Repository package as follows # 
sql> exec dbms_workload_repository.create_snapshot;

Querys to monitor RAC

following few  Query's will help to find out culprits-  Query to check long running transaction from last 8 hours  Col Sid Fo...