Flush specific id and all execution plan from Shared pool in Oracle

Flush specific id and all execution plan from Shared pool in Oracle

Flushing the shared pool lead to hard parse of the SQL queries running from the Application which will degrade the performance also.
You can flush the specific query also instead of flushing the whole shared pool area.

Check wheather SQLAREA plan value present in Shared pool

select ADDRESS, HASH_VALUE from GV$SQLAREA where SQL_ID like '';

select ADDRESS, HASH_VALUE from GV$SQLAREA where PLAN_HASH_VALUE like '';

Script for flush SQL ID from the database shared pool area.

BEGIN
FOR i IN (SELECT address, hash_value FROM gv$sqlarea WHERE sql_id = '&sql_id.')
LOOP
SYS.DBMS_SHARED_POOL.PURGE(i.address||','||i.hash_value, 'C');
END LOOP;
END;
/

Script for flush all SQL id plans present in SQLAREA

BEGIN
FOR i IN (SELECT address, hash_value FROM gv$sqlarea)
LOOP
SYS.DBMS_SHARED_POOL.PURGE(i.address||','||i.hash_value, 'C');
END LOOP;
END;
/

You can flush entire shared pool

Alter system flush shared_pool;

This entry was posted in Oracle on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply