If an SQL is frequently in use and has different SQL plans historically for execution, there might be a scenario that current execution plan in use is a bad one. In that case you might want to get rid of this current plan so that optimizer could possibly load a better plan for next executions. In this case, you would need to invalidate the current cursor in shared pool. Following is the way how we invalidate a SQL cursor from share pool.
Using DBMS_SHARED_POOL.PURGE
Once you find out SQL ID
of the poorly performing SQL (with current bad plan), get the address and hash
value from V$SQLAREA, and then pass as first argument to this procedure.
Remember that you must kill the current sessions executing this SQL otherwise cursor might not get invalided.
SQL> select
address,hash_value from v$sqlarea where sql_id='bqp2ps6zxqxvx'; |
Once done, you can query
v$sesison to find out the sessions executing this SQL, and the child cursor
used by the sessions. From V$SQL you can find which execution plan is in use
now.
SQL>
select sid,serial#,machine,sql_child_number from v$session where
sql_id='bqp2ps6zxqxvx'; |
No comments:
Post a Comment