set lines 200
spool purge.sql
set heading off
set feedback off
set verify off
set echo off
set pages 0
set trimspool on
select 'exec DBMS_SHARED_POOL.PURGE (''' || ADDRESS ||','|| HASH_VALUE || ''',''C'');'
from V$SQLAREA
where SQL_ID IN (SELECT SQL_ID
FROM v$sqlarea
WHERE sql_text like 'SELECT * FROM%SBB.ENTITIY_PR%SYS_P5055%');
select 'exit' from dual;
exit
Execute the file "purge.sql" and the cursors refering to the object "SBB.ENTITY_PR" and the partition "SYS_P5055" will be purged.
The Oracle 19c documentation for dbms_shared_pool can be found here
Minimalistic Oracle contains a collection of practical examples from my encounters with Oracle technologies. When relevant, I also write about other technologies, like Linux or PostgreSQL. Many of the posts starts with "how to" since they derive directly from my own personal experience. My goal is to provide simple examples, so that they can be easily adapted to other situations.
Showing posts with label Purging. Show all posts
Showing posts with label Purging. Show all posts
Friday, June 25, 2021
How to purge tables from the shared pool
Tables cannot be directly purged from the shared pool using the dbms_shared_pool package.
Instead, cursors refering to the table can be purged.
To generate statements, use v$sqlarea:
Wednesday, November 1, 2017
How to purge a cursor from the shared pool using dbms_shared_pool
Find the address and hash value for the particular SQL you're looking for:
Execute the purge procedure:
Note that the name of the object is the combined values of address and hash value from v$sqlarea.
The value C is what you want to use for cursors.
select address, hash_value from v$sqlarea where sql_id like 'bjkd7pcyfns86';
| ADDRESS | HASH_VALUE |
|---|---|
| 0000000085CD2838 | 1021993222 |
Execute the purge procedure:
SQL> exec dbms_shared_pool.purge('0000000085CD2838, 1021993222','C');
Note that the name of the object is the combined values of address and hash value from v$sqlarea.
The value C is what you want to use for cursors.
Note that even if an SQL Plan Baseline is dropped from the SMB, it doesn't mean it won't get used if it is still in the cache.
If you have dropped a plan from your SMB that you would like the optimizer to ignore, you must clear out the cursor that previously using the now dropped SQL Plan baseline from the shared pool using the command above.
Subscribe to:
Comments (Atom)