Latest Updates

Post Top Ad

07 May, 2013

Oracle RDBMS : Flushing a Single SQL Statement out of the Object Library Cache

It is well known that the entire shared pool can be flushed with a simple ALTER SYSTEM statement.
SQL> ALTER SYSTEM FLUSH SHARED_POOL;

System altered.

What if the execution plan of a single SQL statement has to be invalidated or flushed out of the shared pool so the subsequent query execution forces a hard parse on that SQL statement. Oracle 11g introduced a new procedure called PURGE in the DBMS_SHARED_POOL package to flush a specific object such as a cursor, package, sequence, trigger, .. out of the object library cache.
The syntax for the PURGE procedure is shown below.
procedure PURGE (
        name VARCHAR2, 
        flag CHAR DEFAULT 'P', 
        heaps NUMBER DEFAULT 1)

Explanation for each of the arguments is documented in detail in $ORACLE_HOME/rdbms/admin/dbmspool.sql file.
If a single SQL statement has to be flushed out of the object library cache, the first step is to find the address of the handle and the hash value of the cursor that has to go away. Name of the object [to be purged] is the concatenation of the ADDRESS and HASH_VALUE columns from the V$SQLAREA view. Here is an example:
SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '7yc%';

ADDRESS   HASH_VALUE
---------------- ----------
000000085FD77CF0  808321886

SQL> exec DBMS_SHARED_POOL.PURGE ('000000085FD77CF0, 808321886', 'C');

PL/SQL procedure successfully completed.

SQL> select ADDRESS, HASH_VALUE from V$SQLAREA where SQL_ID like '7yc%';

no rows selected

10 comments:

Anonymous said...

Thank you for every other informative website.
Where else could I get that type of information written in such an
ideal approach? I have a undertaking that I am just now running on, and I have been
on the look out for such info.

Here is my page - local small business directory

Anonymous said...

Wow, amazing blog layout! How long have you been blogging for?
you made blogging look easy. The overall look of your web site is great,
as well as the content!

Feel free to surf to my blog post ... bad hair

Anonymous said...

My coder is trying to persuade me to move to .net from PHP.
I have always disliked the idea because of the expenses.
But he's tryiong none the less. I've been using WordPress on numerous websites for about a year
and am nervous about switching to another platform. I have heard
good things about blogengine.net. Is there a way I can import all my wordpress posts into it?
Any help would be greatly appreciated!

my website ... hair loss []

Anonymous said...

Can I just say what a relief to discover
an individual who actually understands what they're talking about on the internet. You definitely realize how to bring an issue to light and make it important. A lot more people ought to check this out and understand this side of the story. I can't
believe you are not more popular given that you
surely have the gift.

Also visit my web blog ... damaged hair

Anonymous said...

We stumbled over here coming from a different web page and thought
I may as well check things out. I like what I see so now i am following you.
Look forward to looking at your web page yet again.


Feel free to surf to my web site; natural hair product ()

Anonymous said...

Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your
point. You definitely know what youre talking about, why waste your intelligence on just
posting videos to your site when you could be giving us something
informative to read?

Take a look at my web-site; fine hair

Anonymous said...

This is a topic that is close to my heart... Cheers!
Where are your contact details though?

Here is my site ... Ultra SLim Patch Review

Anonymous said...

Hi mates, how is the whole thing, and what you desire to
say about this post, in my view its truly amazing for me.


My web page; hair loss :: http://onedollarclick.net/GeriAcker ::

Anonymous said...

Wonderful blog! I found it while surfing around on Yahoo
News. Do you have any suggestions on how to get listed
in Yahoo News? I've been trying for a while but I never seem to get there! Thank you

My page :: best forex robots ()

Anonymous said...

Hmm it looks like your blog ate my first comment (it was
super long) so I guess I'll just sum it up what I had written and say, I'm thoroughly enjoying your
blog. I as well am an aspiring blog writer but I'm still new to everything. Do you have any points for rookie blog writers? I'd certainly appreciate it.


Review my page free forex robot *http://www.xn--schner-wetter-kmb.de/author/HerminePo*

Post Top Ad

Your Ad Spot

Pages