Tuesday, February 7, 2017

Importance of LAST_CALL_ET column in V$session view

Well, we all know the importance of v$session view in oracle. We often look for status,sid,sql_text,program name and other object related things in this table. However there is also one important column inside it which we often tend to ignore which is LAST_CALL_ET(pointed by Connor Mcdonald in his blog-https://connormcdonald.wordpress.com/2016/04/13/active-and-inactive-sessions)


From his blog:

If the session STATUS is currently ACTIVE, then the value represents the elapsed time (in seconds) since the session has become active.

If the session STATUS is currently INACTIVE, then the value represents the elapsed time (in seconds) since the session has become inactive.



Thus this is a great column to get a view on what sessions are doing on your system, for example


select s.sid||','||s.serial# sess,
       s.USERNAME,
       s.last_call_et,
       s.status,
       s.sql_address,
       s.program
from v$session s
where ( s.status = 'ACTIVE' and s.last_call_et > 10 ) or      -- has been active for 10 seconds or more
      ( s.status != 'ACTIVE' and s.last_call_et > 1200 );     -- has been inactive for 20 mins or more


No comments:

Post a Comment