The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question, Duc.
Asked: July 03, 2019 - 4:31 pm UTC
Last updated: April 12, 2021 - 5:16 am UTC
Version: 11.2.0.4
Viewed 10K+ times! This question is
SQL> select sid, serial#, last_call_et 2 from v$session 3 where sql_id = '0qht8ubcqk4wr' -- the "problem" SQL_ID 4 and status = 'ACTIVE' 5 order by 3; SID SERIAL# LAST_CALL_ET ---------- ---------- ------------ 497 744 38 136 13162 45 373 28703 52 3 rows selected.
SQL> set serverout on SQL> declare 2 l_threshold int := 1; 3 l_cnt int := 0; 4 begin 5 for i in ( 6 select sid, serial#, last_call_et 7 from v$session 8 where sql_id = '0qht8ubcqk4wr' 9 and status = 'ACTIVE' 10 order by 3 11 ) 12 loop 13 l_cnt := l_cnt + 1; 14 if l_cnt <= l_threshold then 15 dbms_output.put_line('Leaving SID='||i.sid||' untouched'); 16 else 17 dbms_output.put_line('Killing SID='||i.sid); 18 -- execute immediate 'alter system kill session ....'; 19 end if; 20 end loop; 21 end; 22 / Leaving SID=497 untouched Killing SID=136 Killing SID=373 PL/SQL procedure successfully completed.
Jonas, April 08, 2021 - 12:45 pm UTC
Get all the information about database performance in the Database Performance guide.