DOYENSYS Knowledge Portal




We Welcome you to visit our DOYENSYS KNOWLEDGE PORTAL : Doyensys Knowledge Portal




Thursday, December 29, 2016

Query to find blocking session details for the past by using time interval





Please find the queries below.


1) The below one will show all the sessions.


set lines 170
set pages 10000
col event format a40
col sample_time format a40
select to_char(sample_time,'DD-MON-YY HH24:MI:SS'),SESSION_ID,SESSION_SERIAL#,SQL_ID,BLOCKING_SESSION,BLOCKING_SESSION_SERIAL#,BLOCKING_SESSION_STATUS,EVENT from dba_hist_active_sess_history where to_char(sample_time,'DD-MON-YY HH12:MI:SS') between '19-DEC-16 06:10 PM' and '19-DEC-16 06:20 PM'  and BLOCKING_SESSION is not null order by 1 ;




2) The below one will show the sessions for tx enqueue row lock contention alone.


set lines 170
set pages 10000
col event format a40
col sample_time format a40
select to_char(sample_time,'DD-MON-YY HH24:MI:SS'),SESSION_ID,SESSION_SERIAL#,SQL_ID,BLOCKING_SESSION,BLOCKING_SESSION_SERIAL#,BLOCKING_SESSION_STATUS,EVENT from dba_hist_active_sess_history where to_char(sample_time,'DD-MON-YY HH12:MI:SS') between '19-DEC-16 06:20 PM' and '19-DEC-16 06:30 PM' and event like '%enq:%' and BLOCKING_SESSION is not null order by 1 ;




3) The below one will show the blocking sql text by using the sql_id


set long 10000
set pages 10000
select SQL_FULLTEXT from v$sql where SQL_ID = '&1' and rownum < 2;

No comments: