LAST SQL RAN BEFORE KILLING A SESSION [message #615333] |
Mon, 02 June 2014 10:42  |
azeem87
Messages: 116 Registered: September 2005 Location: dallas
|
Senior Member |
|
|
Hi,
we have an code issue which we know and working to fix that as it's vendor + inhouse code,
for time being till that fix is done we need to avoind an issue of too many inactive connections, where connections are not being closed by APP code,
I have this SQL to kill the session since we know from which machine they are coming from,
can i have a SQL that will show the last ran SQL from these SID's that will be killed , to be more specific to find which code is having this issue.
SELECT 'alter system kill session '''
|| sid
|| ','
|| serial#
|| ',@'
|| inst_id
|| ''' immediate ;'
FROM gv$session
WHERE status LIKE 'INACTIVE'
AND username LIKE 'APPLICATIONUSER%'
and MACHINE='abc.yx.net'
AND last_call_et > 2000;
Thanks
|
|
|
|
Re: LAST SQL RAN BEFORE KILLING A SESSION [message #615337 is a reply to message #615335] |
Mon, 02 June 2014 11:38   |
azeem87
Messages: 116 Registered: September 2005 Location: dallas
|
Senior Member |
|
|
thanks for quick response..
i tried this , and cancelled after 1 mins.. do you think this will take time..
inner select comes back in 2 secs.
select sql_text from gv$sql where sql_id in (select prev_sql_id from gv$session WHERE status LIKE 'INACTIVE'
AND username LIKE 'APPLICATIONUSER%'
and MACHINE='abc.yx.net'
AND last_call_et > 200)
|
|
|
|
Re: LAST SQL RAN BEFORE KILLING A SESSION [message #615339 is a reply to message #615338] |
Mon, 02 June 2014 12:10   |
azeem87
Messages: 116 Registered: September 2005 Location: dallas
|
Senior Member |
|
|
thanks Michel,
we are on RAC, so was using GV$,
inner select is still good with in 2 secs, the complete SQL still same.. might SQL_TEXT column/sql_fulltext ( clob ) takes time..?
don't want to run too long also in prod cancelled again after 3 mins..
any other thoughts.
thanks for your time.
[Updated on: Mon, 02 June 2014 12:14] Report message to a moderator
|
|
|
|
|
|
Re: LAST SQL RAN BEFORE KILLING A SESSION [message #615346 is a reply to message #615343] |
Mon, 02 June 2014 13:07   |
azeem87
Messages: 116 Registered: September 2005 Location: dallas
|
Senior Member |
|
|
SQL_TEXT 7 is just VARCHAR2 (64 Byte) in gv$sqltext
so the output is something like this
1. ADDENDA = :6 , STATUS = :7 WHERE TNUM = :8
2. S'') || TO_CHAR(TEMPLATETNUM) || TO_CHAR(TEMPLATE_PROTECTFIELD
this trimmed data, either from starting or at the end it's trimmed really doesn't gives full idea on the complete SQL.
but performance on gv$SQLTEXT is great.. in 1 sec..
[Updated on: Mon, 02 June 2014 13:07] Report message to a moderator
|
|
|
|
|