Assume there exists a table DEPARTMENT. Table EMPLOYEE references DEPARTMENT using field SYS_DEPT_ID. When SYS_DEPT_ID is not indexed, and EMPLOYEE has large no of rows, this can cause long-running TM lock on delete of a DEPARTMENT row because oracle has to figure out if there are any employees working on this department or not. You can use Oracle Grid control to see the wait events and if you see a TM contention wait event than use the following query to identify these types of missing indexes so they can be added.
SELECT * FROM (
SELECT c.table_name, cc.column_name, cc.position column_position
FROM user_constraints c, user_cons_columns cc
WHERE c.constraint_name = cc.constraint_name
AND c.constraint_type = 'R'
MINUS
SELECT i.table_name, ic.column_name, ic.column_position
FROM user_indexes i, user_ind_columns ic
WHERE i.index_name = ic.index_name
)
ORDER BY table_name, column_position;
SELECT * FROM (
SELECT c.table_name, cc.column_name, cc.position column_position
FROM user_constraints c, user_cons_columns cc
WHERE c.constraint_name = cc.constraint_name
AND c.constraint_type = 'R'
MINUS
SELECT i.table_name, ic.column_name, ic.column_position
FROM user_indexes i, user_ind_columns ic
WHERE i.index_name = ic.index_name
)
ORDER BY table_name, column_position;
Comments
Post a Comment