Oracle 根据SQL_ID查询并杀会话,清空执行计划缓冲池

1. 查询最近五分钟内最高频次SQL,查看event

select t.SQL_OPNAME,t.SQL_ID,count(*) from v$active_session_history t where t.SAMPLE_TIME>to_timestamp('20180906-09:55:00','YYYYMMDD-hh24:mi:ss') and t.SESSION_TYPE='FOREGROUND'
group by t.SQL_OPNAME,t.SQL_ID order by count(*) desc;
 

2、 根据SQL 查询到操作用户

select s.username from v$active_session_history t,dba_users s  where t.USER_ID=s.user_id and t.SQL_ID='0nx7fbv1w5xg2';

 

3、查询并获取当前sql的杀会话语句

select 'alter system kill session '''|| t.SID||','||t.SERIAL#||''';' from v$session t where t.SQL_ID='0nx7fbv1w5xg2';
 

Oracle 根据SQL_ID查询并杀会话,清空执行计划缓冲池_第1张图片

4、查询并获取当前会话的执行计划清空过程语句

select SQL_TEXT,sql_id, address, hash_value, executions, loads, parse_calls, invalidations  
from v$sqlarea  where sql_id='0nx7fbv1w5xg2';

call sys.dbms_shared_pool.purge('0000000816530A98,3284334050','c');

你可能感兴趣的:(ORACLE,ORACLE,优化)