Pages

Monday, October 13, 2014

AWR by example. Generating and Reading AWR Report

=======================
How to generate AWR Report
=======================

Step A - Get possible step_id 

COL BEGIN_INTERVAL_TIME FOR A30
COL END_INTERVAL_TIME FOR A30
SELECT SNAP_ID, DBID, INSTANCE_NUMBER, BEGIN_INTERVAL_TIME, END_INTERVAL_TIME 
FROM DBA_HIST_SNAPSHOT
WHERE TO_CHAR(TRUNC(BEGIN_INTERVAL_TIME),'YYYYMMDD') = '20141206'

  SNAP_ID       DBID INSTANCE BEGIN_INTERVAL_TIME         END_INTERVAL_TIME
---------- ---------- ------- --------------------------- --------------------------
     33907  907411508       1 07-DEC-14 01.00.39.792 AM   07-DEC-14 02.00.42.754 AM
     33913  907411508       1 07-DEC-14 07.00.57.651 AM   07-DEC-14 08.01.00.724 AM
     33912  907411508       1 07-DEC-14 06.00.54.538 AM   07-DEC-14 07.00.57.651 AM
     33914  907411508       1 07-DEC-14 08.01.00.724 AM   07-DEC-14 09.00.03.790 AM

Step B - Generate AWR Report

Option I - via sqlplus from Oracle server.

sqlplus system/xxx@orainst @/software/oracle/111/rdbms/admin/awrrpt.sql


====================
.set_profile
====================
export ORACLE_SID=orainst
export ORACLE_BASE=/software/oracle
export ORACLE_HOME=/software/oracle/111
export PATH=$PATH:$ORACLE_HOME/bin/
====================
./generate_awr.sh
====================
#! /bin/bash
. /etc/sh/orash/oracle_login.sh igt

sqlplus system/xxx@orainst @${ORACLE_HOME}/rdbms/admin/awrrpt.sql


The report would be generated to current working directory.

Option II - via sqlplus from remote server.

SELECT OUTPUT 
FROM TABLE(DBMS_WORKLOAD_REPOSITORY.awr_report_html
( :DBID, :SID, :start_snap_id, :finish_snap_id);

For Example:
SELECT OUTPUT 
FROM TABLE(DBMS_WORKLOAD_REPOSITORY.awr_report_html
( 37534411, 1, 3001, 3007);

Where:
:DBID <= SELECT dbid FROM V$DATABASE;
:SID  <= SELECT instance_number FROM V$INSTANCE;
:start_snap_id and :finish_snap_id <= SELECT * FROM DBA_HIST_SNAPSHOT

The report would be generated to sqlplus standard output.


Create snap_id on demand
To create snap_id on demand:
EXECUTE DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
or
EXECUTE DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT('ALL');
CREATE_SNAPSHOT function receives only one parameter: FLUSH_LEVEL
Default value is 'TYPICAL',
Alternative value is 'ALL'. Per Oracle documentation: "When the statistics level is set to ALL, the AWR gathers the maximum amount of performance data."

Parse in AWR Report.

TheorySoft Parse vs Hard Parse.
The parsing process performs two main functions:
First Step:
- Statement Syntax Check.
- Statement Objects check (Does table exists, permissions, etc...)
Second Step:
The next step is to get the Execution Plan
- First check if the statement we are currently parsing has already in fact been processed by some other session.
- If YES - We get the execution plan and row source for execution from Library cache.
                   This is the Soft Parse.
- If NO -  Oracle must must parse, optimize and generate the plan for the query.
                  This is the Hard Parse.

Parsing info in AWR Report


Load Profile section.

Load Profile
Per SecondPer TransactionPer ExecPer Call
DB Time(s):0.10.20.000.00
DB CPU(s):0.10.10.000.00
Redo size:156,764.6217,590.6
Logical reads:1,223.01,697.5
Block changes:282.5392.1
Physical reads:206.2286.3
Physical writes:114.4158.8
User calls:59.582.6
Parses:2.53.5
Hard parses:0.20.3
W/A MB processed:48,220.266,930.1
Logons:0.10.1
Executes:73.9102.5
Rollbacks:0.00.0
Transactions:0.7


ParsesThe total of all parses; both hard and soft.
Hard Parses:  The parses requiring a completely new parse of the SQL statement. These consume both latches and shared pool area.
Soft ParsesSoft parses are not listed but derived by subtracting the hard parses from parses.

Instance Efficiency Percentages (Target 100%) section.

Instance Efficiency Percentages (Target 100%)
Buffer Nowait %:100.00Redo NoWait %:100.00
Buffer Hit %:92.47In-memory Sort %:100.00
Library Hit %:99.24Soft Parse %:92.89
Execute to Parse %:96.57Latch Hit %:99.98
Parse CPU to Parse Elapsd %:0.00% Non-Parse CPU:99.47



Buffer Hit % – Percent of requested blocks read from the buffer cache vs blocks read from disk.



Library Hit % – Ratio that shows how often requested SQL was found in Library cache. 100 % means that where were no hard parses at all. Low value may indicate too small library cache, SQLs not using bind variables, frequent invalidation of referred objects or just that system was just started.



Execute to Parse % – Ratio that shows number of executions to number of parses.



Parse CPU to Parse Elapsd% – Parse Elapsd is sum of Parse CPU and Waits. This ratio show how much time was spent on waits for latches during parsing. If Waits are low then this ration will be high and vise versa. Target is 100%(no waits for latches).


Soft Parse % – Soft Parses to Hard Parses. Target is 100% – all sql is in the cache and no Hard Parse occurred.

Execute to Parse % Elaborated
This ration is calculated as following:
'Execute to Parse %:’, ROUND(100*(1-:prse/:exe),2)

From Tom Kyte article in Oracle Magazine: 
   "My preferred way to improve your execute-to-parse ratio, is to move all the SQL out of the client application and into stored procedures. 
   PL/SQL is a statement caching machine. When you say “close this cursor” in PL/SQL, PL/SQL tells you, “OK, it’s closed,” but it really isn’t. The PL/SQL engine smartly keeps the cursor open, knowing that you are just going to call that stored procedure and execute that SQL again."


AWR Report has a section "SQL ordered by Parse Calls"
Is it Soft Parse, or Hard Parse, or both?
AWR Does not have a good distinction between Soft Parse and Hard Parse


What to check?

1. Top SQL with Top Row Sources 
This will show bottlenecks in instance.
Such as FULL SCANs




2. ADDM Task ADDM
This will show the top issues, as per ADDM report
For example:

ADDM Task ADDM:1255688165_1_14003

          ADDM Report for Task 'ADDM:1255688165_1_14003'
          ----------------------------------------------

Analysis Period
---------------
AWR snapshot range from 14002 to 14003.
Time period starts at 01-JUN-21 02.00.48 PM
Time period ends at 01-JUN-21 03.00.16 PM

Analysis Target
---------------
Database 'IGT' with DB ID 1255688165.
Database version 12.2.0.1.0.
ADDM performed an analysis of instance igt, numbered 1 and hosted at
qanfv-1-dbs-1a.

Activity During the Analysis Period
-----------------------------------
Total database time was 68821 seconds.
The average number of active sessions was 19.29.

Summary of Findings
-------------------
   Description           Active Sessions      Recommendations
                         Percent of Activity
   --------------------  -------------------  ---------------
1  Top SQL Statements    18.17 | 94.2         2
2  CPU Usage             2.49 | 12.89         2
3  Buffer Cache Latches  .4 | 2.07            0


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


          Findings and Recommendations
          ----------------------------

Finding 1: Top SQL Statements
Impact is 18.17 active sessions, 94.2% of total activity.
---------------------------------------------------------
SQL statements consuming significant database time were found. These
statements offer a good opportunity for performance improvement.

   Recommendation 1: SQL Tuning
   Estimated benefit is 9.14 active sessions, 47.4% of total activity.
   -------------------------------------------------------------------
   Action
      Run SQL Tuning Advisor on the SELECT statement with SQL_ID
      "1qkunjg7g6twp".
      Related Object
         SQL statement with SQL_ID 1qkunjg7g6twp.
         select * from SGA_W_PSMS_SUBSCRIBER where IMSI = :1  AND AFFILIATE_ID
         = :2  ORDER BY TS_E_LAST_LU ASC
   Rationale
      The SQL spent 88% of its database time on CPU, I/O and Cluster waits.
      This part of database time may be improved by the SQL Tuning Advisor.
   Rationale
      Database time for this SQL was divided as follows: 100% for SQL
      execution, 0% for parsing, 0% for PL/SQL execution and 0% for Java
      execution.
   Rationale
      SQL statement with SQL_ID "1qkunjg7g6twp" was executed 4184399 times and
      had an average elapsed time of 0.0086 seconds.

   Recommendation 2: SQL Tuning
   Estimated benefit is 7.8 active sessions, 40.43% of total activity.

3. Top 5 Timed Foreground Events


Free Buffer waits
Large value indicate lack of memory.
Data blocks are read from disk, into the Buffer Cache.
In case there is not enough memory, Free Buffer wait occurs.
This could be a result of a combination of too low memory, and not effective application, doing not selective enough fetches from database.

Per Oracle documentation:
This event occurs mainly when a server process is trying to read a new buffer into the buffer cache but too many buffers are either pinned or dirty and thus unavailable for reuse. 
The session posts to DBWR then waits for DBWR to create free buffers by writing out dirty buffers to disk.
DBWR may not be keeping up with writing dirty buffers in the following situations:
  • The I/O system is slow.
  • There are resources it is waiting for, such as latches.
  • The buffer cache is so small that DBWR spends most of it's time cleaning out buffers for server processes.
  • The buffer cache is so big that one DBWR process is not enough to free enough buffers in the cache to satisfy requests.
What to do:
1. Increase the buffer cache.
2. Check that I/O is evenly distributed.
Run this query to see if the I/O is evenly distributed.

SELECT name, phyrds, phywrts      
  FROM v$filestat a, v$datafile b    
  WHERE a.file# = b.file#


Below is a real example of an effect of increasing MAX_MEMORY and MAX_MEMORY_TARGET, from 4Gb to 8Gb, on free buffer waits wait event.

Before memory increase, "Free Buffer Waits" was constantly in the Top 5 Timed Foreground Events list, usually on 1st or 2nd place, along with "DB File Sequential Read".

Obviously Instance was having a heavy I/O load and not keeping up with I/O requests.

After memory increase, the "Free Buffer Wait" was significantly lower.


Before memory increase:


After memory increase:
















Instance Efficiency Percentages(Target 100%)





The low value of Soft Parse - suggest to little shared Library Cache.


Buffer Busy Waits vs Free Buffer Waits












Free Buffer Waits
Free Buffer Waits wait event indicates that a server process was unable to find a free buffer and has posted the database writer to make free buffers by writing out dirty buffers.

Buffer Busy Waits
Buffer Busy Waits occur when an Oracle session needs to access a block in the buffer cache, but cannot because the buffer copy of the data block is locked. 

Buffer busy wait condition can happen for either of the following reasons:
* The block is being read into the buffer by another session, so the waiting session must wait for the block read to complete. 
* Another session has the buffer block locked in a mode that is incompatible with the waiting session's request.

The solution for Free Buffer Waits commonly includes tuning I/O, and increasing the size of the buffer cache.

The solution for Buffer Busy Waits includes tuning indexes to reduce amount of data blocks loaded into shared pool.



SGA Target Advisory

In this example, Per Oracle SGA Target Advisory, performance should benefit from another 2Gb addition to SGA.


SQL ordered by Parse Calls

e CallsExecutions% Total ParsesSQL IdSQL ModuleSQL Text
26,27426,27413.089tgj4g8y4rwy8select type#, blocks, extents,...
10,08410,0845.027ykawc7v0hc24Data Pump WorkerSELECT CONDITION FROM SYS.CDEF...
8,4048,4044.190h6b2sajwb74nselect privilege#, level from ...
5,0315,0312.51bsa0wjtftg3uwselect file# from file$ where ...
3,4183,4181.7015uz111g14124Data Pump WorkerSELECT ACTION# FROM SYS.TRIGGE...
3,1503,1501.5730hzffxbsfct8JDBC Thin Clientselect producttre0_.ITEM_ID as...
3,1323,1321.56459f3z9u4fb3uselect value$ from props$ wher...
2,9502,9501.47350f5yrnnmshslock table sys.mon_mods$ in ex...
2,9502,9501.47g00cj285jmgswupdate sys.mon_mods$ set inser...
2,9402,9401.460ws7ahf1d78qaselect SYS_CONTEXT('USERENV', ...
2,8482,8481.42crxwzb62uga8dJDBC Thin ClientSELECT TRIGGER_NAME, TRIGGER_...
2,6102,6101.300k8522rmdzg4kselect privilege# from sysauth...
2,4212,4211.215ur69atw3vfhjselect decode(failover_method,...
2,4002,4001.201uzhrfn574t12sqlplus@my_server (TNS V1-V3)SELECT ATTRIBUTE, SCOPE, NUMER...
2,4002,4001.204d4ayw5argrgzdbrefresh@my_server (TNS V1-V3)SELECT TABLE_ID, ISN, MAP_NA...
2,4002,4001.205qgz1p0cut7mxsqlplus@my_server (TNS V1-V3)BEGIN DBMS_OUTPUT.DISABLE; END...
2,4002,4001.20c4pc3jhzjcmc7sqlplus@my_server (TNS V1-V3)SELECT CHAR_VALUE FROM SYSTEM....
2,4002,4001.20d6vwqbw6r2ffksqlplus@my_server (TNS V1-V3)SELECT USER FROM DUAL
2,4002,4001.20dyk4dprp70d74SQL*PlusSELECT DECODE('A', 'A', '1', '...
2,4002,4001.20g4y6nw3tts7ccsqlplus@my_server (TNS V1-V3)BEGIN DBMS_APPLICATION_INFO.SE...
2,3992,3991.190u3dq44mn09pnsqlplus@v(TNS V1-V3)select INSTANCE_NAME||STATUS f...
2,2412,2411.127qd215rsryu1urman@my_server (TNS V1-V3)declare thread number; seque...

In this section there is no definition between soft parse and hard parse.


SQL ordered by Version Count

Version CountExecutionsSQL IdSQL ModuleSQL Text
2241,2907pcmxut6628hdJDBC Thin ClientMERGE into SGA_W_SUBSCRIBER o ...
1617,6567ng34ruy5awxqselect i.obj#, i.ts#, i.file#,...
1617,6567ng34ruy5awxqselect i.obj#, i.ts#, i.file#,...
1617,6567ng34ruy5awxqselect i.obj#, i.ts#, i.file#,...
1182,315a73wbv1yu8x5cselect con#, type#, condlength...
1188,689dwypdxsjg4juqselect /*+ index_ss(obj$ i_obj...
1188,689dwypdxsjg4juqselect /*+ index_ss(obj$ i_obj...
1136,8902q93zsrvbdw48select grantee#, privilege#, n...
1033,0611gu8t96d0bdmuselect t.ts#, t.file#, t.block...
1033,0611gu8t96d0bdmuselect t.ts#, t.file#, t.block...
10318,84396g93hntrzjtrselect /*+ rule */ bucket_cnt,...
9610,0785n1fs4m2n2y0rselect pos#, intcol#, col#, sp...
926,8866aq34nj2zb2n7select col#, grantee#, privi...
90426aq4js2gkfjru8update tsq$ set blocks=:3, max...
8713,90053saa2zkr6wc3select intcol#, nvl(pos#, 0), ...
8713,90053saa2zkr6wc3select intcol#, nvl(pos#, 0), ...
69462dgtxysfq8yq97select o.owner#, o.name, ...
6226,2749tgj4g8y4rwy8select type#, blocks, extents,...

Why would SQL have many versions?

For lack of obvious reasons, one possibility, is that the SQL statements are invalidated between each execution. 

Tom Kyte note on "Why do we see several entries for same SQL statement in V$SQL"

Per Tom Kyte, all SQL versions should be listed in V$SQL_SHARED_CURSOR table.

However, the data displayed in AWR Report is not reflecting that.
For example: for sql_id 7pcmxut6628hd per AWR Report there are 224 version.
But in table V$SQL_SHARED_CURSOR there are only 8 entries.
And all 8, have bind_mismatch='Y'.



SQL Ordered by Gets
Buffer Gets (also called Logical Reads) means the data is already in the data buffer cache and Oracle is trying to locate the rows that match the WHERE clause.
A high number of Buffer Gets means two things:
(1) 
Oracle is working very hard to locate the matching rows because of an unrestrictive WHERE clause or bad/missing indexes;
(2) High CPU since Oracle 
counts the time it’s doing Buffer Gets as CPU time.












Real case scenario
The top SQL in the AWR Report is doing a Full Table Scan against a table that has only 12,000 rows.

But then, looking into USER_SEGMENTS:

SELECT SUM(bytes/1024/1024) AS Mb FROM USER_SEGMENTS WHERE segment_name ='MY_TABLE'


The result is 672 Mb!!!
The reason, is that this tables undergoes a lot of DML operations.



The steps to address this situation:
ALTER SESSION SET DDL_LOCK_TIMEOUT = 600;
ALTER TABLE MY_TABLE ENABLE ROW MOVEMENT;
ALTER TABLE MY_TABLE SHRINK SPACE;



Real case scenario - disabling an unused index - big effect on Index Tablespace IO.
A database has a large table, approx 10,000,000 rows, with 4 indexes on this table.
Two of the indexes on that table were not used by the Optimizer.
These indexes were on a YES/NO column, so obviously Oracle Optimizer choose not to use them.
(2 Distinct values, for 10,000,000 entries!) 
So Oracle was constantly updating the unused index, splitting blocks, etc.

These two indexes were dropped.

Below are AWR Tablespace IO Stats from two runs, one week apart.
The first AWR screenshot shows DB Writes on Index Tablespace before dropping the indexes.
The first AWR screenshot shows DB Writes on Index Tablespace after dropping the indexes.
The time frame is 24 hours, 7 days apart.

There was approx 5% decrease in overall activity during the second run.
The I/O activity on Data Tablespace (IGT_TABLE) has decreased by 4%.
The I/O activity on Index Tablespace (IGT_INDEX) has decreased by nearly 90%.!!! 
Tablespace IO Stats
  • ordered by IOs (Reads + Writes) desc

Tablespace
Reads
Av Reads/s
Av Rd(ms)
Av Blks/Rd
Writes
Av Writes/s
Buffer Waits
Av Buf Wt(ms)
IGT_TABLE
13,357,884
161
0.24
1.10
8,140,422
98
334
1.29
IGT_INDEX
2,239,321
27
0.58
1.00
2,449,789
30
215
0.51
UNDOTBS
3,878
0
4.18
1.00
94,343
1
500
0.42
SYSAUX
40,405
0
1.22
2.56
13,181
0
0
0.00
WORKAREA
23,539
0
0.08
1.11
28,934
0
0
0.00
SYSTEM
24,958
0
2.10
3.65
2,943
0
123
1.06
DWH_TABLE
2,135
0
0.87
2.60
147
0
0
0.00
TEMPORARY
193
0
0.05
5.62
125
0
0
0.00
DWH_INDEX
147
0
5.44
1.00
147
0
0
0.00
GIN
147
0
0.54
1.00
147
0
0
0.00
GININDEX
147
0
0.54
1.00
147
0
0
0.00





Tablespace IO Stats
  • ordered by IOs (Reads + Writes) desc

Tablespace
Reads
Av Reads/s
Av Rd(ms)
Av Blks/Rd
Writes
Av Writes/s
Buffer Waits
Av Buf Wt(ms)
IGT_TABLE
13,205,936
167
0.19
1.10
7,813,737
99
408
0.78
IGT_INDEX
1,526,675
19
0.56
1.00
272,469
3
228
0.26
UNDOTBS
2,920
0
5.42
1.00
89,058
1
305
0.59
SYSAUX
41,172
1
1.07
2.45
13,093
0
0
0.00
WORKAREA
23,468
0
0.12
1.11
27,968
0
0
0.00
SYSTEM
25,279
0
1.71
3.48
3,188
0
129
0.54
DWH_TABLE
2,124
0
1.11
2.60
136
0
0
0.00
TEMPORARY
176
0
0.06
7.00
132
0
0
0.00
DWH_INDEX
136
0
5.07
1.00
136
0
0
0.00
GIN
136
0
0.29
1.00
136
0
0
0.00
GININDEX
136
0
0.29
1.00
136
0
0
0.00


In addition, check out the Buffer Wait Statistics section.


A lot of the waits are coming from UNDO TBS.
This is sync with high Buffer Wait in Undo TBS.
Solution: increase the size of UNTO TBS

SELECT tablespace_name, extent_management, segment_space_management 
FROM DBA_TABLESPACES 
WHERE tablespace_name = 'UNDOTBS';

TABLESPACE_NAME                EXTENT_MAN SEGMEN
------------------------------ ---------- ------
UNDOTBS                        LOCAL      MANUAL


SELECT tablespace_name, file_name, 
       ROUND(maxbytes/1024/1204) as MAX_MB, 
       ROUND(bytes/1024/1204) as USED_MB   
  FROM DBA_DATA_FILES 
  WHERE tablespace_name='UNDOTBS';


TABLESPACE_NAME FILE_NAME                                MAX_MB USED_MB
--------------- ---------------------------------------- ------ -------
UNDOTBS         /oracle_db/db1/db_igt/ora_undotbs_01.dbf   1701    1446


ALTER DATABASE DATAFILE '/oracle_db/db1/db_igt/ora_undotbs_01.dbf' RESIZE 3000M;
Database altered.


Appendix
Reading AWR Report
How to read AWR reports
Tom Kyte note on "Why do we see several entries for same SQL statement in V$SQL"

===============================
Where is the path for alert.log
===============================
Query V$DIAG_INFO
INST_ID NAME                VALUE
------- ------------------- -------------------------------------------------------------
      1 Diag Enabled        TRUE
      1 ADR Base            d:\software\oracle
      1 ADR Home            d:\software\oracle\diag\rdbms\igt\igt
      1 Diag Trace          d:\software\oracle\diag\rdbms\igt\igt\trace
      1 Diag Alert          d:\software\oracle\diag\rdbms\igt\igt\alert
      1 Diag Incident       d:\software\oracle\diag\rdbms\igt\igt\incident
      1 Diag Cdump          d:\software\oracle\diag\rdbms\igt\igt\cdump
      1 Health Monitor      d:\software\oracle\diag\rdbms\igt\igt\hm
      1 Default Trace File  d:\software\oracle\diag\rdbms\igt\igt\trace\igt_ora_42388.trc

11 rows selected


Read Types and Read Wait Events.

There are three types of read WAIT events: 


a) db file sequential read (single block IO). 
This reads into the buffer cache, you do a logical IO after this read to get the block out. 

b) db file scattered read (multi-block IO, we scatter the blocks in the buffer cache). 
This reads into the buffer cache, you do logical IO's after this read to get the blocks out. 

c) Direct path read (usually, but not always, done with parallel queries - can be done with serial queries these days as well). 
This read bypasses the buffer cache, we read from disk directly into your pga avoiding the overhead of the buffer cache. 

There are two types of reads: 

a) single block IO 
b) multi block IO 


Reads vs Gets
Gets are Logical Reads.
Reads in AWR are Physical Reads


===============================
No Data in AWR Report
===============================
1. Check out the value for parameter CONTROL_MANAGEMENT_PACK_ACCESS
When running AWR report, there is no data, and only these messages in the generated report file.

No data exists for this section of the report.

Check out the value for parameter CONTROL_MANAGEMENT_PACK_ACCESS

SQL> show parameter control_management

NAME                                 TYPE        VALUE
------------------------------------ ----------- ----------
control_management_pack_access       string      NONE

If it is set to NONE, set it to 'DIAGNOSTIC+TUNING'

ALTER SYSTEM SET CONTROL_MANAGEMENT_PACK_ACCESS='DIAGNOSTIC+TUNING' scope=both; 
System altered.


================================
Change the interval and retention settings
================================
SELECT snap_interval, retention 
  FROM DBA_HIST_WR_CONTROL;

SNAP_INTERVAL                  RETENTION
------------------------------ ------------------------------
+00000 00:15:00.0              +00008 00:00:00.0

Change the interval to 30 minutes
BEGIN
 DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(interval => 30);
END;
/

PL/SQL procedure successfully completed.


SQL>  SELECT snap_interval, retention FROM DBA_HIST_WR_CONTROL;

SNAP_INTERVAL                  RETENTION
------------------------------ ------------------------------
+00000 00:30:00.0              +00008 00:00:00.0

Change the interval to 7 days

1440*7=10080 minutes

BEGIN
 DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(retention => 10080);
END;
/

ERROR at line 1:
ORA-13541: system moving window baseline size (691200) greater than retention


SELECT baseline_type, moving_window_size FROM DBA_HIST_BASELINE;

BASELINE_TYPE MOVING_WINDOW_SIZE
------------- ------------------
MOVING_WINDOW                  8

First need to change the baseline window size to 7 days.
Then can lower retention to 7 days.

Change the Window size to equal to retention of 7 days
BEGIN
 DBMS_WORKLOAD_REPOSITORY.modify_baseline_window_size(window_size=> 7);
END;
/
PL/SQL procedure successfully completed.

BEGIN
 DBMS_WORKLOAD_REPOSITORY.modify_snapshot_settings(retention => 10080);
END;
/
PL/SQL procedure successfully completed.

SELECT snap_interval, retention FROM DBA_HIST_WR_CONTROL;

SNAP_INTERVAL                  RETENTION
------------------------------ ------------------------------
+00000 00:30:00.0              +00007 00:00:00.0


2. Check out the Oracle Edition
oracle@my_host:~>% sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Mon Nov 23 02:17:58 2015

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

Connected to:

Oracle Database 11g Release 11.2.0.4.0 - 64bit Production

SQL> SELECT * FROM V$VERSION;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production

NLSRTL Version 11.2.0.4.0 - Production

This is Standard Edition (In EE there is Oracle Database 11Enterprise Edition Release 11.2.0.4.0 - 64bit Production)

In Standard Edition

Word of Warning
This functionality is separately licensed Oracle Database option.
Oracle 11  - Database Licensing Information



No comments:

Post a Comment