Purging a single execution plan out of the shared pool (10.2)

 Oracle  Comments Off on Purging a single execution plan out of the shared pool (10.2)
Oct 202010
 

(tested on 10.2.0.4.1)
I needed this today and I want to share the solution i found in Harald’s blog.

One single query started to work slow. It takes more than an hour, instead of a few seconds. An, of course, nobody touched this piece of code for months.

It was easy to see that the plan makes FTS of one of the biggest tables in the database. And I could see this only in v$sql_plan – if I try explain plan it promises to use an index.

I used SELECT * FROM TABLE(dbms_xplan.display_awr('&sql_id')); and I saw the plan gone wrong today. The old executions were using the index access. What caused this change (a bad one) – nobody knows. I did not invest much time on this. The question is how to remove the query out of the library cache, so that it could generate a new (old) indexed plan.

The most dramatic approach is alter system flush shared_pool. It’s like putting your house on fire to kill that mises inside. Yes, this plan will possibly get better, another one may get worse, and that will be combined with a lot of CPU usage until all statements get parsed again. No, thanks.

Another idea is to invalidate the cursor by running some DDL on one of the tables referenced by the query. We have plenty of options for this – like putting a comment (yes, this is a DDL). An alternative approach is to set column statistics for some column (w/o actually changing the values). But again, this is too “general”- all statements on this table will be invalidated.

Harald’s solution is much more elegant. The package dbms_shared_pool has a procedure purge, which makes what I need – removes “something” (like a cursor or a package) from the library cache. This is new in 11.1, but it is so useful, that Oracle decided to backport it to 10.2.0.4. But there are some details.

First, our dbms_shared_pool did not provide this procedure (although the database is 10.2.0.4.1). This can be fixed using:
@?/rdbms/admin/dbmspool

Then I tested it again and again – it did not work at all. The procedure executes just fine, but does not make any change. Then I started reading the comments in Harald’s blog and I found this:
alter session set events '5614566 trace name context forever';

This fixed the procedure:
select address, hash_value from v$sqlarea where sql_id = '1mqxxf66dtgdp';
exec sys.dbms_shared_pool.PURGE('0000000A5C166350, 2363276725', 'C');

The value of the third parameter (C) stands for “Cursor”. The other options are:
— Value Kind of Object to keep
— —– ———————-
— P package/procedure/function
— Q sequence
— R trigger
— T type
— JS java source
— JC java class
— JR java resource
— JD java shared data
— C cursor

This is it. It works, and it is useful.

 Posted by at 14:19

ASM 11.2 error ORA-15038

 Oracle  Comments Off on ASM 11.2 error ORA-15038
Oct 152010
 

The error appears upon starting the ASM instance mounting a diskgroup manually

ORA-15032: not all alterations performed
ORA-15040: diskgroup is incomplete
. . .
ORA-15038: disk **** mismatch on 'Time Stamp' with target disk group [1752361090] [1751191692]

THis happend to us right after an upgrade of the ASM an was kind of thrilling. I thought we damaged some of the disk headers during the upgrade.

But the problem is far smaller. You just need to fix the value of asm_diskstring. With the right string, it works like charm.

11.1 would show far less shocking error message in this case…

 Posted by at 14:26

Quote of the day

 Oracle  Comments Off on Quote of the day
Oct 112010
 

Complexity is the IT equivalent of communist bureaucracy – it isn’t remotely interesting, it wastes colossal amounts of time, and it ultimately causes the system to go down.

I would say this is equivalent to any heavy bureaucracy – communist, European or US…

Credits: James Morale’s blogSane SAN 2010: Fibre Channel – Ready, Aim, Fire

 Posted by at 22:41

If this is not the case, the try something else…

 Oracle  Comments Off on If this is not the case, the try something else…
Oct 082010
 

This is part of the Upgrade script for 11.2.0.2:

#######################################################################
#######################################################################
## The following statement may cause an
## ORA-29554: unhandled Java out of memory condition
## error.
## If so, this is because there is insufficient system tablespace,
## shared or java pool size, or some other resource value is too small.
## An additional message describing the problem will be output by
## the statement.
#######################################################################
#######################################################################

In other words, “if the statement fails, “something” is wrong – fix it” 🙂

By the way, the script is rock-solid. I have made many 11.2 upgrades, works like charm. You just have to fulfill the requirements provided by utlu112i.

(I didn’t try DBUA – I guess it works fine too)

 Posted by at 14:33