当前会话查询
bash
with tmp_table_index as (
select di.owner||'.'||di.index_name as index_name_with_owner,
di.table_owner||'.'||di.table_name as table_name_with_owner
from dba_indexes di
)
select sysdate,dh.sql_id,dh.ROW_WAIT_OBJ#,
(select t0.table_name_with_owner
from dba_objects do ,tmp_table_index t0
where do.object_id=dh.ROW_WAIT_OBJ# and do.owner||'.'||do.object_name = t0.index_name_with_owner) as table_name_with_owner,
(select t0.index_name_with_owner
from dba_objects do ,tmp_table_index t0
where do.object_id=dh.ROW_WAIT_OBJ# and do.owner||'.'||do.object_name = t0.index_name_with_owner) as index_name_with_owner,
dh.event,dh.program,dh.machine
from gv$session dh
where 1=1
and dh.event in ('enq: TX - index contention')
;
历史信息查询
bash
with tmp_table_index as (
select di.owner||'.'||di.index_name as index_name_with_owner,
di.table_owner||'.'||di.table_name as table_name_with_owner
from dba_indexes di
)
select dh.sample_time,dh.sql_opname,dh.sql_id,dh.current_obj#,
(select t0.table_name_with_owner
from dba_objects do ,tmp_table_index t0
where do.object_id=dh.current_obj# and do.owner||'.'||do.object_name = t0.index_name_with_owner) as table_name_with_owner,
(select t0.index_name_with_owner
from dba_objects do ,tmp_table_index t0
where do.object_id=dh.current_obj# and do.owner||'.'||do.object_name = t0.index_name_with_owner) as index_name_with_owner,
dh.event,dh.program,dh.machine
from gv$active_session_history dh
--dba_hist_active_sess_history dh
where 1=1
and dh.event in ('enq: TX - index contention')
and dh.sample_time between to_date('2026-03-25 00:00:00','yyyy-mm-dd hh24:mi:ss')
and to_date('2026-03-25 23:59:59','yyyy-mm-dd hh24:mi:ss')
;