Wikipedia

Search results

Oracle DBMS_SHARED_POOL


Oracle DBMS_SHARED_POOL
Version 12.2.0.1


General Information
Library Note
The Library is currently in the process of being upgraded from Oracle Database Version 12.1.0.2 to 12.2.0.1.
 Demos are being upgraded to reflect the new Container paradigm as well as EBR (Edition Based Redefinition)
 and may contain references to CDBs, PDBs, and other objects you may not be familiar
 with such as CDB_OBJECTS_AE: Welcome to 12c.

Do you remember when mainframes were replaced by client-server? When client-server was replaced by n-tier architecture?

 The "Cloud" is a distraction ... DevOps is not. Prepare for the future.
PurposePin and unpin objects in memory
AUTHIDDEFINER
Dependencies
DBMS_OUTPUTDBMS_UTILITYV$SQLAREA
DBMS_SQLTCB_INTERNALV$DB_OBJECT_CACHEX$KGLOB
DBMS_STANDARD
DocumentedYes
First Available10gR1
Security ModelOwned by SYS with EXECUTE granted to the EXECUTE_CATALOG_ROLE role
Source{ORACLE_HOME}/rdbms/admin/dbmspool.sql
Subprograms
ABORTED_REQUEST_THRESHOLD
Sets the aborted request threshold for the shared pooldbms_shared_pool.aborted_request_threshold(threshold_size IN NUMBER);

-- the range of threshold_size is 5000 to ~2 GB inclusive
exec dbms_shared_pool.aborted_request_threshold(100000000);
KEEP
Pin A Cursor In Memory

Overload 1
dbmsdbms_shared_pool.keep(name IN VARCHAR2, flag IN CHAR DEFAULT 'P');

Flag ValuesDescription
Ccursor
JCjava class
JDjava shared data
JRjava resource
JSjava source
Pprocedure
Qsequence
Rtrigger
Ttype
conn sys@pdbdev as sysdba

GRANT select ON gv_$open_cursor TO uwclass;

conn uwclass/uwclass@pdbdev

-- SQL statement to load cursor into the shared pool
VARIABLE x REFCURSOR

BEGIN
   OPEN :x for
   SELECT *
   FROM all_tables;
END;
/

--Determine address and hash value of the SQL statement
SELECT address, hash_value
FROM gv$open_cursor
WHERE sql_text LIKE '%ALL_TABLES%';

-- substitute your query results for mine, below
exec sys.dbms_shared_pool.keep('1C5B28DC, 3958201300', 'C');

conn sys@pdbdev as sysdba

SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND TYPE = 'CURSOR';
Pin A Package, Procedure Or Function In Memory (this is the default)SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';

CREATE OR REPLACE PROCEDURE testproc IS
BEGIN
  NULL;
END testproc;
/

exec sys.dbms_shared_pool.keep('testproc', 'P');

conn sys@pdbdev as sysdba

col owner format a30

SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';
Pin A Sequence In Memoryconn sys@pdbdev as sysdba
SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';

conn uwclass/uwclass@pdbdev

CREATE SEQUENCE seq_test;

exec sys.dbms_shared_pool.keep('seq_test', 'Q');

conn sys@pdbdev as sysdba

SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';
Pin A Trigger In Memoryconn uwclass/uwclass@pdbdev

SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';

CREATE TABLE t (
testcol VARCHAR2(20));

CREATE OR REPLACE TRIGGER testtrig
BEFORE UPDATE
ON t
BEGIN
   NULL;
END testtrig;
/

exec sys.dbms_shared_pool.keep('testtrig', 'R');

conn sys@pdbdev as sysdba

SELECT owner, name, type
FROM gv$db_object_cache
WHERE kept = 'YES'
AND owner = 'UWCLASS';
Overload 2dbms_shared_pool.keep(
schema    IN VARCHAR2,
objname   IN VARCHAR2,
namespace IN NUMBER,
heaps     IN NUMBER);
TBD
Overload 3dbms_shared_pool.keep(
hash      IN VARCHAR2,
namespace IN NUMBER,
heaps     IN NUMBER);
TBD
MARKHOT
Mark a library cache object as a hot object

Overload 1
dbms_shared_pool.markhot(
schema    IN VARCHAR2,
objname   IN VARCHAR2,
namespace IN NUMBER  DEFAULT 1,     -- library cache namespace to search
global    IN BOOLEAN DEFAULT TRUE); -- If TRUE mark hot on all RAC instances
TBD
Overload 2dbms_shared_pool.markhot(
hash      IN VARCHAR2,              -- 16-byte hash value for the object
namespace IN NUMBER  DEFAULT 1,
global    IN BOOLEAN DEFAULT TRUE);
CREATE OR REPLACE TRIGGER pin_markhot_objects
AFTER STARTUP ON DATABASE
BEGIN
  dbms_shared_pool.markhot(hash=>'01630e17906c4f222031266c21b49303',namespace=>0);
  dbms_shared_pool.markhot(hash=>'119df082543f104e29cad00ee793c8aa',namespace=>0);
  dbms_shared_pool.markhot(hash=>'251d24517d18ee7b2154e091b80e64d2',namespace=>0);
  dbms_shared_pool.markhot(hash=>'28104e170c4020b7d6991509b4886443',namespace=>0);
  dbms_shared_pool.markhot(hash=>'3362900d064bc7d9a1812303ea49391e',namespace=>0);
END;
/
PURGE
Purge the named object or particular heap(s) of the object

Overload 1
dbms_shared_pool.purge(
name  IN VARCHAR2,
flag  IN CHAR   DEFAULT 'P',
heaps IN NUMBER DEFAULT 1);


Note: heaps to purge. e.g if heap 0 and heap 6 are to be purged.
1<<0 | 1<<6 => hex 0x41 => decimal 65. so specify heaps=>65.
Default is 1 i.e heap 0 which means the whole object will be purged.

In some versions this may not work unless you set event 5614566 so
I have shown that in this demo. It is not necessary in 11gR1 or above.
conn sys@pdbdev as sysdba

alter session set events '5614566 trace name context forever';

SELECT /* find me */ COUNT(*)
FROM dba_tables t, dba_indexes i
WHERE t.table_name = i.table_name;

SELECT address, hash_value, sql_text
FROM v$sqlarea
WHERE sql_text LIKE '%find me%';

exec dbms_shared_pool.purge('385C52F8,943808449', 5'c');

SELECT address, hash_value, sql_text
FROM v$sqlarea
WHERE sql_text LIKE '%find me%';
Purge the named object or particular heap(s) of the object

Overload 2
dbms_shared_pool.purge(
schema    IN VARCHAR2,
objname   IN VARCHAR2,
namespace IN NUMBER,
heaps     IN NUMBER);
TBD
Purge the object or particular heap(s) of the object

Overload 3
dbms_shared_pool.purge(
hash      IN VARCHAR2,
namespace IN NUMBER,
heaps     IN NUMBER);
TBD
SIZES
Shows what is in the Shared Pool larger than a specified size in bytesdbms_shared_pool.sizes(minsize IN NUMBER);
set serveroutput on

exec dbms_shared_pool.sizes(500);
UNKEEP
Unkeep the named object
Overload 1
dbms_shared_pool.unkeep(name IN VARCHAR2, flag IN CHAR DEFAULT 'P');
exec dbms_shared_pool.unkeep('UWCLASS.TESTPROC', 'P');
Unkeep an object in the shared pool

Overload 2
dbms_shared_pool.unkeep(
schema    IN VARCHAR2,
objname   IN VARCHAR2,
namespace IN NUMBER);
TBD
Overload 3dbms_shared_pool.unkeep(
hash      IN VARCHAR2,
namespace IN NUMBER);
TBD
UNMARKHOT
Unmark a library cache object as a hot object

Overload 1
dbms_shared_pool.unmarkhot(
schema    IN VARCHAR2,
objname   IN VARCHAR2,
namespace IN NUMBER  DEFAULT 1,
global    IN BOOLEAN DEFAULT TRUE);
TBD
Overload 2dbms_shared_pool.unmarkhot(
hash      IN VARHAR2,
namespace IN NUMBER  DEFAULT 1,
global    IN BOOLEAN DEFAULT TRUE);
exec dbms_shared_pool.unmarkhot(hash=>'7eb6e0f357f73998ba9116f63f50f54e',namespace=>0);
Related Queries
Find information on pinned cursorsSELECT address, hash_value
FROM gv$sqlarea
WHERE sql_text LIKE '%<name_from_v$db_object_cache%';

Troubleshooting Assistant: Resolve Issues with Oracle Undo Management (ORA-01555, ORA-30036, ORA-01628, ORA-01552, etc.)

Troubleshooting Assistant: Resolve Issues with Oracle Undo Management (ORA-01555, ORA-30036, ORA-01628, ORA-01552, etc.)

It save your time in searching related doc on ORA- issue fix.

Just try the Oracle Support doc assistance -

(Doc ID 1575667.2)  Troubleshooting Assistant

Data Guard Physical Standby - Managing temporary tablespace tempfiles

The management of temporary tablespaces and tempfiles in an environment where you want to maintain a consistent configuration across the Primary and Standby sites.
The addition of temporary files to TEMP tablespaces in the primary site is not handled automatically through the normal redo apply mechanisms in the same way as regular datafiles if the parameter standby_file_management is set to AUTO.  The DBA must manually synchronised the primary and standby tempfile configuration if they require both the sites to be the same.
Note: tempfiles are established during an RMAN duplicate operation, this document details the process for managing tempfiles that are added to environments only after the standby has been built and is running.

Administering the addition of a tempfile to an existing temporary tablespace in the Primary and Standby sites

NOTE : The BEST Practice/ Rerequisites of Switchover is to Check for TEMP and and create one if it is not present before SWITCHOVER/FAILOVER.
Refer,


1. Add the temp file in the primary

Primary Site
SQL> alter tablespace temp add tempfile '+DATA' size 50M;

Tablespace altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------
+DATA/rs1/tempfile/temp.264.800115667
+DATA/rs1/tempfile/temp.273.802356687

SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     221
Next log sequence to archive   223
Current log sequence           223
SQL> alter system switch logfile;

System altered.

2. The tempfile will NOT automatically be created in the physical standby.

Standby Site 

The tempfile thats has been added to the Primary site file is not automatically replicated to the Standby site like regular datafiles.
There is still only one tempfile in the Standby database even though there are now 2 tempfiles in the Primary.
The parameter standby_file_management=AUTO has no impact on tempfile management in the environment.
SQL> recover managed standby database disconnect;
Media recovery complete.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/rs1_stb/tempfile/temp.264.800115667

 
Even after log switches occur in the primary the file is not replicated (for those environments relying on archivelogs and ARCH as the shipping mechanism)

Primary Site
SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     221
Next log sequence to archive   223
Current log sequence           223
Standby Alert Log
Tue Dec 18 12:51:51 2012
Archived Log entry 215 added for thread 1 sequence 222 ID 0x6cb514f6 dest 1:
Tue Dec 18 12:51:54 2012
Media Recovery Log +FRA/rs1_stb/archivelog/2012_12_18/thread_1_seq_222.485.802356711
Media Recovery Waiting for thread 1 sequence 223 (in transit)
Tue Dec 18 12:55:15 2012
Standby controlfile consistent with primary

 
Standby Site

There is still no tempfile appearing at the standby site even though recovery is running, standby_file_management=AUTO and log switching has occurred
SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     221
Next log sequence to archive   0
Current log sequence           223
SQL> select name from v$tempfile;         

NAME
--------------------------------------------------------------------------------
+DATA/rs1_stb/tempfile/temp.264.800115667

3. Tempfiles will not be created as a part of the switchover or failover process

During a switchover operation the file is not created or replicated to the new primary site.  It must be added manually.  In this case it will be performed using the Data Guard broker command line utility.

Primary Site
DGMGRL> connect sys@rs1_prm_dgmgrl
Password:
Connected.

DGMGRL> show configuration;

Configuration - rs1_dg

  Protection Mode: MaxAvailability
  Databases:
    rs1     - Primary database
    rs1_stb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
DISABLED

DGMGRL> enable configuration;
Enabled.
DGMGRL> show configuration;

Configuration - rs1_dg

  Protection Mode: MaxAvailability
  Databases:
    rs1     - Primary database
    rs1_stb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> switchover to rs1_stb
Performing switchover NOW, please wait...
New primary database "rs1_stb" is opening...
Operation requires shutdown of instance "rs1" on database "rs1"
Shutting down instance "rs1"...
ORACLE instance shut down.
Operation requires startup of instance "rs1" on database "rs1"
Starting instance "rs1"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "rs1_stb"

The alert log in the standby site shows nothing about the addition of the tempfile that has been built into the Primary sites configuration.
The alert log extract below shows the switchover operations from the perspective of the standby site.
Standby Alert Log
Tue Dec 18 12:58:57 2012
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE  THROUGH ALL SWITCHOVER DISCONNECT  USING CURRENT LOGFILE
Tue Dec 18 12:58:58 2012
Standby controlfile consistent with primary
RFS[2]: Selected log 5 for thread 1 sequence 225 dbid 1823795963 branch 800115647
Media Recovery Waiting for thread 1 sequence 224 (in transit)
Tue Dec 18 12:58:58 2012
Archived Log entry 217 added for thread 1 sequence 224 ID 0x6cb514f6 dest 1:
Media Recovery Log +FRA/rs1_stb/archivelog/2012_12_18/thread_1_seq_224.487.802357139
Media Recovery Waiting for thread 1 sequence 225 (in transit)
Recovery of Online Redo Log: Thread 1 Group 5 Seq 225 Reading mem 0
  Mem# 0: +DATA/rs1_stb/onlinelog/group_5.275.801239591
  Mem# 1: +FRA/rs1_stb/onlinelog/group_5.459.801239593
Tue Dec 18 12:59:36 2012
RFS[2]: Selected log 4 for thread 1 sequence 226 dbid 1823795963 branch 800115647
Tue Dec 18 12:59:36 2012
Archived Log entry 218 added for thread 1 sequence 225 ID 0x6cb514f6 dest 1:
Tue Dec 18 12:59:37 2012
Media Recovery Waiting for thread 1 sequence 226 (in transit)
Recovery of Online Redo Log: Thread 1 Group 4 Seq 226 Reading mem 0
  Mem# 0: +DATA/rs1_stb/onlinelog/group_4.274.801239589
  Mem# 1: +FRA/rs1_stb/onlinelog/group_4.458.801239591
RFS[2]: Possible network disconnect with primary database
Tue Dec 18 12:59:40 2012
RFS[4]: Assigned to RFS process 3788
RFS[4]: Selected log 4 for thread 1 sequence 226 dbid 1823795963 branch 800115647
Resetting standby activation ID 1823806710 (0x6cb514f6)
Media Recovery End-Of-Redo indicator encountered
Media Recovery Continuing
Tue Dec 18 12:59:40 2012
Archived Log entry 219 added for thread 1 sequence 226 ID 0x6cb514f6 dest 1:
Media Recovery Waiting for thread 1 sequence 227
Tue Dec 18 12:59:40 2012
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
MRP0: Background Media Recovery cancelled with status 16037
Errors in file /u01/app/oracle/diag/rdbms/rs1_stb/rs1/trace/rs1_pr00_3763.trc:
ORA-16037: user requested cancel of managed recovery operation
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Tue Dec 18 12:59:42 2012
MRP0: Background Media Recovery process shutdown (rs1)
Managed Standby Recovery Canceled (rs1)
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WAIT WITH SESSION SHUTDOWN
ALTER DATABASE SWITCHOVER TO PRIMARY (rs1)
Maximum wait for role transition is 15 minutes.
krsv_proc_kill: Killing 3 processes (all RFS)
Backup controlfile written to trace file /u01/app/oracle/diag/rdbms/rs1_stb/rs1/trace/rs1_rsm0_3759.trc
SwitchOver after complete recovery through change 2653587
Online log +DATA/rs1_stb/onlinelog/group_1.276.801239713: Thread 1 Group 1 was previously cleared
Online log +FRA/rs1_stb/onlinelog/group_1.327.801239715: Thread 1 Group 1 was previously cleared
Online log +DATA/rs1_stb/onlinelog/group_2.277.801239715: Thread 1 Group 2 was previously cleared
Online log +FRA/rs1_stb/onlinelog/group_2.316.801239715: Thread 1 Group 2 was previously cleared
Online log +DATA/rs1_stb/onlinelog/group_3.278.801239719: Thread 1 Group 3 was previously cleared
Online log +FRA/rs1_stb/onlinelog/group_3.315.801239719: Thread 1 Group 3 was previously cleared
Standby became primary SCN: 2653585
Switchover: Complete - Database mounted as primary
Completed: ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WAIT WITH SESSION SHUTDOWN
ARC3: Becoming the 'no SRL' ARCH
ALTER SYSTEM SET log_archive_dest_2='service="rs1_prm"','LGWR SYNC AFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="rs1" net_timeout=30','valid_for=(all_logfiles,primary_role)' SCOPE=BOTH;
ALTER DATABASE OPEN
Data Guard Broker initializing...
Tue Dec 18 12:59:48 2012
Assigning activation ID 1826002576 (0x6cd69690)
LGWR: Primary database is in MAXIMUM AVAILABILITY mode
Destination LOG_ARCHIVE_DEST_2 is UNSYNCHRONIZED
LGWR: Destination LOG_ARCHIVE_DEST_1 is not serviced by LGWR
Thread 1 advanced to log sequence 228 (thread open)
Tue Dec 18 12:59:48 2012
ARC0: Becoming the 'no SRL' ARCH
Thread 1 opened at log sequence 228
  Current log# 2 seq# 228 mem# 0: +DATA/rs1_stb/onlinelog/group_2.277.801239715
  Current log# 2 seq# 228 mem# 1: +FRA/rs1_stb/onlinelog/group_2.316.801239715
Successful open of redo thread 1
ARC3: Becoming the 'no SRL' ARCH
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
Tue Dec 18 12:59:49 2012
SMON: enabling cache recovery
Tue Dec 18 12:59:49 2012
..
.
TNS-12564: TNS:connection refused
    ns secondary err code: 0
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0
Error 12514 received logging on to the standby
PING[ARC2]: Heartbeat failed to connect to standby 'rs1_prm'. Error is 12514.

[3759] Successfully onlined Undo Tablespace 2.
Undo initialization finished serial:0 start:329674 end:330254 diff:580 (5 seconds)
Dictionary check beginning
Tue Dec 18 12:59:50 2012
Errors in file /u01/app/oracle/diag/rdbms/rs1_stb/rs1/trace/rs1_dbw0_3585.trc: <<<<<<<<<<<<<<<<ERRORS ON TEMP
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DATA/rs1_stb/tempfile/temp.264.800115667'
ORA-17503: ksfdopn:2 Failed to open file +DATA/rs1_stb/tempfile/temp.264.800115667
ORA-15012: ASM file '+DATA/rs1_stb/tempfile/temp.264.800115667' does not exist
Errors in file /u01/app/oracle/diag/rdbms/rs1_stb/rs1/trace/rs1_dbw0_3585.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '+DATA/rs1_stb/tempfile/temp.264.800115667'
File 201 not verified due to error ORA-01157
Tue Dec 18 12:59:50 2012
Dictionary check complete
Verifying file header compatibility for 11g tablespace encryption..
Verifying 11g file header compatibility for tablespace encryption completed
SMON: enabling tx recovery
Re-creating tempfile +DATA/rs1_stb/tempfile/temp.264.800115667 as +DATA/rs1_stb/tempfile/temp.280.802357191
Database Characterset is WE8MSWIN1252
No Resource Manager plan active
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
Tue Dec 18 12:59:53 2012
QMNC started with pid=24, OS id=3790
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Completed: ALTER DATABASE OPEN
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='rs1';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='rs1';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
ALTER SYSTEM SET db_file_name_convert='rs1','rs1_stb' SCOPE=SPFILE;
ALTER SYSTEM SET log_file_name_convert='rs1','rs1_stb' SCOPE=SPFILE;
ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH;
ALTER SYSTEM ARCHIVE LOG
ARC2: STARTING ARCH PROCESSES
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Tue Dec 18 12:59:57 2012
ARC4 started with pid=30, OS id=3792
Tue Dec 18 12:59:57 2012
.
CJQ0 started with pid=45, OS id=3818
Tue Dec 18 13:00:14 2012
Shutting down archive processes
ARCH shutting down
ARC4: Archival stopped
Tue Dec 18 13:00:14 2012
db_recovery_file_dest_size of 4122 MB is 55.46% used. This is a
user-specified limit on the amount of space that will be used by this
database for recovery-related files, and does not reflect the amount of
space available in the underlying filesystem or ASM diskgroup.
Tue Dec 18 13:00:35 2012
ALTER SYSTEM SET log_archive_dest_state_2='ENABLE' SCOPE=BOTH;
ALTER SYSTEM ARCHIVE LOG
Tue Dec 18 13:00:37 2012
LGWR: Standby redo logfile selected to archive thread 1 sequence 230
LGWR: Standby redo logfile selected for thread 1 sequence 230 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 230 (LGWR switch)
  Current log# 1 seq# 230 mem# 0: +DATA/rs1_stb/onlinelog/group_1.276.801239713
  Current log# 1 seq# 230 mem# 1: +FRA/rs1_stb/onlinelog/group_1.327.801239715
Tue Dec 18 13:00:37 2012
ARC3: Becoming the 'no SRL' ARCH
Tue Dec 18 13:00:37 2012
ARC0: Becoming the 'no SRL' ARCH
ARC3: Becoming the 'no SRL' ARCH
Archived Log entry 222 added for thread 1 sequence 229 ID 0x6cd69690 dest 1:
ARC3: Becoming the 'no SRL' ARCH
ARC3: Standby redo logfile selected for thread 1 sequence 229 for destination LOG_ARCHIVE_DEST_2
Thread 1 cannot allocate new log, sequence 231
Checkpoint not complete
  Current log# 1 seq# 230 mem# 0: +DATA/rs1_stb/onlinelog/group_1.276.801239713
  Current log# 1 seq# 230 mem# 1: +FRA/rs1_stb/onlinelog/group_1.327.801239715
Tue Dec 18 13:00:49 2012
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
LGWR: Standby redo logfile selected to archive thread 1 sequence 231
LGWR: Standby redo logfile selected for thread 1 sequence 231 for destination LOG_ARCHIVE_DEST_2
Thread 1 advanced to log sequence 231 (LGWR switch)
  Current log# 2 seq# 231 mem# 0: +DATA/rs1_stb/onlinelog/group_2.277.801239715
  Current log# 2 seq# 231 mem# 1: +FRA/rs1_stb/onlinelog/group_2.316.801239715
Tue Dec 18 13:00:51 2012
ARC3: Becoming the 'no SRL' ARCH
Archived Log entry 227 added for thread 1 sequence 230 ID 0x6cd69690 dest 1:

4. You must add the new tempfile to the new primary site manually after the switchover is complete.  This will ensure you maintain the same tempfile structures across the Primary and Standby sites.

New Primary Site
SQL> alter tablespace temp add tempfile '+DATA' size 50M;

Tablespace altered.

SQL>  select name from v$tempfile;  

NAME
--------------------------------------------------------------------------------
+DATA/rs1_stb/tempfile/temp.280.802357191
+DATA/rs1_stb/tempfile/temp.281.802357385

5. If a tempfile is added to the Primary and the standby site is OPEN READ ONLY you can add the new temp file manually to the Standby even if no switchover has been performed.

New Primary Site
A new file is added to the new Primary in this case the Old Standby site that is currently running in the Primary role.
SQL> alter tablespace temp add tempfile '+DATA' size 20M;

Tablespace altered.

SQL> alter system switch logfile;

System altered.

SQL> archive log list
Database log mode           Archive Mode
Automatic archival           Enabled
Archive destination           USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     230
Next log sequence to archive   232
Current log sequence           232


New Standby Site
To demonstrate the Standby will be opened read only and the tempfile added manually to the sites configuration.
SQL> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SQL> recover managed standby database cancel;
Media recovery complete.
SQL> alter database open;

Database altered.

As this an 11.2 environment Active Data Guard can be running while this file is built into the standby sites structure.  Managed recovery is started in this demonstration.
SQL> recover managed standby database disconnect using current logfile;
Media recovery complete.
 The new 20M tempfile that was added to the Primary has not been replicated, is not a part of the standby sites structure and must be added manually if we want both sites tempfile configuration to be the same.
SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/rs1/tempfile/temp.264.800115667
+DATA/rs1/tempfile/temp.273.802356687

SQL> alter tablespace temp add tempfile '+DATA' size 20M;

Tablespace altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/rs1/tempfile/temp.264.800115667
+DATA/rs1/tempfile/temp.273.802356687
+DATA/rs1/tempfile/temp.274.802357821

 Reference -   Oracle (Doc ID 1514588.1) [Release 10.2 to 12.1]

Sharing Memory—Automatically

TECHNOLOGY: Talking Tuning


Sharing Memory—Automatically (By Kimberly Floss)                                                                                         Published In 

Oracle Magazine

Put away your scripts and let Oracle automatically resize your memory pools.
It used to be a challenge to size the various memory pools that comprise the Oracle system global area (SGA) for optimal performance. But that was before Oracle Database 10g.
For example, the buffer cache had to be large enough to keep frequently used blocks readily available for fast retrieval—but not so large that the database couldn't allocate memory in one of the other SGA pools when needed. Since various types of applications and usage patterns tax the assorted pools differently, and since the workload can vary minute by minute, manuall y resizing the SGA components could feel like a never-ending task.
If there wasn't enough free SGA to allocate memory to a specific pool when needed, the database would raise an out-of-memory error, such as 
ORA-04031: unable to allocate ...


Also, before Oracle9i Database Release 2, adjusting the pool sizes required bouncing the server—hardly practical in a production environment.
That's why Oracle Database 10g's Automatic Shared Memory Management (ASMM) is such a welcome improvement. First introduced in Oracle Database 10g and further enhanced in Oracle Database 10g Release 2, ASMM automatically sizes many of the memory pools while the database is running, allocating and de-allocating memory as needed. As the workload composition changes, Oracle Database 10g enlarges the appropriate pools and reduces the sizes of other automatically sized pools accordingly. In short, ASMM can save you a lot of trouble—and improve overall performance as well.
Let's take a closer look at how it works and how to use it.

SGA Memory Components

The linchpin of Oracle Database 10g's memory management scheme is the new SGA_TARGETinitialization parameter. The value of this setting determines the total amount of SGA memory that can be allocated across both manually and automatically sized pools. (See Table 1, in the online version of this article at oracle.com/technology/oramag/oracle/ 05-sep/o55tuning.html.) TheSGA_TARGET value imposes a ceiling on the amount of RAM devoted to the Oracle SGA.
Oracle Database 10g Release 2 can automatically tune the size of the shared pool, buffer cache, Java pool, large pool, and streams pool. However, you must still manually tune several SGA components, including the log buffer (at startup time only), the keep buffer cache, the recycle buffer cache, and all of the nonstandard block-size buffer caches (for example, the 32K and 16K buffer caches set by the db_32K_cache_size and db_16K_cache_size parameters). Manually sized components consume SGA from the target value first, and then the remainder of SGA memory is spread across the various autosized pools. In other words, if you set parameter values for any of these manually tuned pools, Oracle Database 10g Release 2 subtracts their sizes from SGA_TARGET first, before allocating memory to the automatically allocated pools.
The SGA_TARGET setting value also includes a small amount of fixed-size SGA. Oracle Database 10g Release 2 sets the fixed size based on the operating system and other criteria. You can see the amount (in bytes) of the fixed-size SGA and totals of other major elements that occupy the SGA by querying the V$SGA view, as follows: 
SQL> select * from v$sga;
NAME                      VALUE
------------------        ----------
Fixed Size                  1247780
Variable Size             124319196
Database Buffers           41943040
Redo Buffers                 262144


You can query this same view to determine an initial size for SGA_TARGET when you switch from manual to autotuning, by summing all the components as follows: 
SQL> select sum(value)/1024/1024 "Megabytes" from v$sga;

Megabytes
------------------
 160


Listing 1 shows an example of total real memory allocation for the current SGA from theV$SGA_DYNAMIC_COMPONENTS view (introduced in Oracle9i Database), which contains both manual and autotuned SGA components.
Code Listing 1: Query of V$SGA_DYNAMIC_COMPONENTS 
SQL> select component, current_size from v$sga_dynamic_components;

COMPONENT                          CURRENT_SIZE
-------------------------------     ------------
shared pool                         92274688
large pool                           8388608
java pool                            8388608
streams pool                        12582912
DEFAULT buffer cache                33554432
KEEP buffer cache                    4194304
RECYCLE buffer cache                 4194304
DEFAULT 2K buffer cache                    0
DEFAULT 4K buffer cache                    0
DEFAULT 8K buffer cache                    0
DEFAULT 16K buffer cache                   0
DEFAULT 32K buffer cache                   0
ASM Buffer Cache                           0

13 rows selected.


Using ASMM

As with the other manageability features of Oracle Database 10g, ASMM requires you to set theSTATISTICS_LEVEL parameter to at least TYPICAL (the default), so make sure this setting is correct before you try to enable ASMM. You can enable it in the following ways: 
  • Set SGA_TARGET to a nonzero value in the initialization parameter file (pfile).
  • Use Oracle Enterprise Manager (or Oracle Grid Control) or ALTER SYSTEM to dynamically set a nonzero value for SGA_TARGET in the server parameter file (spfile).
To use the command line ( ALTER SYSTEM ), set a value for SGA_TARGET and then set the parameters for all of the autotuned pools to 0, as follows: 
SQL> alter system set sga_target=160M scope=both;
System altered.

SQL> alter system set db_cache_size=0;
System altered.

SQL> alter system set shared_pool_size=0;
System altered.

<
                               repeat for each autotuned pool>
                            


If you don't set the values for each of the autotuned pools to zero after switching to ASMM, whatever value you had set for a parameter will function as a lower threshold value for that pool—ASMM won't go below a nonzero value, even if it needs the memory for another autotuned pool.
Rather than entering each of these ALTER SYSTEM commands for each of the autotuned pools as shown above, you can use Oracle Enterprise Manager to accomplish the same thing in one step, as part of the switch from Manual to Automatic tuning, by clicking the Enable button on the Memory Parameters page. This also shows you at a glance the various memory allocations at any time. To open the Memory Parameters page, from Database Control's Administration page, click the Advisor Central link (under the Related Links heading near the bottom of the page), and then click the Memory Advisor link.
The Memory Parameters page shows the memory allocations across all major components over time, since the last restart of the database, as shown in Figure 1. Lower down on the page you'll see a pie chart and a table displaying the Current Allocations. The chart shows the allocations as percentages of the total SGA that can be allocated, while the table shows the component and a value, in megabytes, of the allocation.
Figure 1: Memory Parameters page

Also on the Memory Parameter page, adjacent to the Total SGA Size field, is an Advice button—new in Oracle Database 10g Release 2. This lets you assess the impact of increasing (or decreasing) the system's target SGA. The v$sga_target_advice view also provides this information, as shown in Listing 2.
The v$sga_target_advice view gives you the information you need to modify theSGA_TARGET parameter (up to the size of the SGA_MAX_SIZE , if necessary). For the example in Listing 2, we can increase the SGA_TARGET to 200 and thereby reduce physical reads by about 10%.
Code Listing 2: Query of V$SGA_TARGET_ADVICE 
                               
SQL> select sga_size, sga_size_factor, estd_db_time, estd_db_time_factor, estd_physical_reads
 from v$sga_target_advice order by sga_size_factor;
 SGA_SIZE     SGA_SIZE_FACTOR     ESTD_DB_TIME      ESTD_DB_TIME_FACTOR    ESTD_PHYSICAL_READS
---------    -----------------   --------------    -------------------    -------------------
120           .75                421               1                      26042
160          1                   421               1                       8223
240          1.5                 421               1                       7340
280          1.75                421               1                       7340       
200          1.25                421               1                       7340
320          2                   421               1                       7340

6 rows selected.
                       

SHARED_POOL_SIZE Value in Oracle Database 10g 


In Oracle Database 10g, the shared pool size is the actual value of the parameter only—yet the overhead must still be accounted for in the shared pool. This means that if you're migrating to Oracle Database 10g from a prior release and you plan to manually size the various memory pools, you must make the shared_pool_size parameter value slightly larger in Oracle Database 10g than in your prior release to account for the startup overhead. In Oracle Database 10g, you can see precisely how much this startup overhead is by querying the v$sgainfodynamic view—you'll find a value for "Startup overhead in shared pool."If you're going to manually tune Oracle Database 10g SGA pools, note one key difference in how it interprets the shared pool value. In releases prior to Oracle Database 10g, the shared pool size was set equal to the shared_pool_sizeinitialization parameter value, plus the amount of internal SGA overhead—memory that the database allocated during startup to maintain state for various server components of the SGA. So if you set theshared_pool_sizeparameter to 48M in Oracle9i Database, for example, the actual shared pool size allocated by the database might have been 60MB, assuming a startup overhead amount of 12MB. 

Conclusion

It doesn't matter how much memory the system has if it's not properly allocated across the appropriate SGA pools at runtime. Yet since the system requirements can change from one minute to the next, these pools must be constantly adjusted. Oracle Database 10g's ASMM is a huge time-saver, and it also reduces the chances of ORA-04031 errors. The result? Your system will perform better—and you'll save time and trouble.