Dear Readers, In this article, we will see the Oracle : Important Queries to check Blocking sessions (SecureCRT). Menubar : Blocking Tab : Blocking Sessions
|
set linesize 300 select B.USERNAME ||' ('||B.SID||','||B.SERIAL#||',@'||B.INST_ID||') is Currently '||B.STATUS||' for last '||B.LAST_CALL_ET||' Sec and it''s BLOCKING user '|| W.USERNAME|| ' ('| |W.SID||','||W.SERIAL#||',@'||W.INST_ID||')' from (select INST_ID,SID,SERIAL#,USERNAME,STATUS,BLOCKING_INSTANCE,BLOCKING_SESSION, LAST_CALL_ET from gv$session where BLOCKING_SESSION >0) W, (select INST_ID,SID,SERIAL#,USERNAME,STATUS,LAST_CALL_ET from gv$session ) B where W.BLOCKING_INSTANCE=B.INST_ID and W.BLOCKING_SESSION=B.SID; B.USERNAME||'('||B.SID||','||B.SERIAL#||',@'||B.INST_ID||')ISCURRENTLY'||B.STATUS||'FORLAST'||B.LAST_CALL_ET|| -------------------------------------------------------------------------------------------------------------- ------------------------------------------------------------------- VINOD (51,25124,@1) is Currently INACTIVE for last 48 Sec and it's BLOCKING user VINOD (57,30908,@1) |
Tab : Blocking_session_event
|
set linesize 300 set pagesize 100 col machine for a50 col event for a50 col username for a25 select inst_id,sid,serial#,username,event,status,sql_id,BLOCKING_SESSION,machine from gv$session where event like '%lock%' or event like '%latch%' or event like '%buffer%' or event='latch: row cache objects' or event='enq: TM - contention' or event='enq:_TX_-_index_contention' and type!='BACKGROUND' order by 1; INST_ID SID SERIAL# USERNAME EVENT STATUS SQL_ID BLOCKING_SESSION MACHINE ---------- ---------- ---------- ------------------------- -------------------------------------------------- -------- ------------- ---------------- ------------- 1 57 30908 VINOD enq: TX - row lock contention ACTIVE dbc1d3gdvz06s 51 awsserver123 |
Tab : SQLs INVOLVED IN BLOCKING
|
set head on PROMPT ##################################################################################### PROMPT SQLs INVOLVED IN BLOCKING PROMPT ##################################################################################### set pagesize 100 set linesize 300 col sql_text for a100 col SQL_ID for a30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
SELECT distinct /*+ RULE */ SQL_ID, sql_text FROM GV$SQL WHERE SQL_ID IN ( select SQL_ID from (select SQL_ID from gv$session where BLOCKING_SESSION >0) union select B.SQL_ID --Blocker Current SQL from (select INST_ID,SID,BLOCKING_INSTANCE,BLOCKING_SESSION from gv$session where BLOCKING_SESSION >0) W, (select INST_ID,SID,SERIAL#,SQL_ID from gv$session ) B where W.BLOCKING_INSTANCE=B.INST_ID and W.BLOCKING_SESSION=B.SID union select B.PREV_SQL_ID --Blocker PRIV SQL from (select INST_ID,SID,BLOCKING_INSTANCE,BLOCKING_SESSION from gv$session where BLOCKING_SESSION >0) W, (select INST_ID,SID,SERIAL#,PREV_SQL_ID from gv$session ) B where W.BLOCKING_INSTANCE=B.INST_ID and W.BLOCKING_SESSION=B.SID ) ORDER BY sql_id; SQL_ID SQL_TEXT ------------------------------ -------------------------------- dbc1d3gdvz06s update test set a=3 where a=1 |
Tab : Objects involved in Blocking Lock… Read More