Tom,
I used the following script to identify FK columns without indexes.
Thanks, Karthik
On 27-Jun-05, at 5:18 PM, Mercadante, Thomas F (LABOR) wrote:
Karthik,
As you have figured out, the largest cause of Deadlock problems are bad coding and missing indexes to support foreign keys. Below is a sql to help you find tables with foreign keys but no indexes to support them. The query is not 100% bullet proof, but it is a start.
I use this for Curam applications as they do not believe in supplying indexes for foreign keys (their official response is to drop the FK's - nice, eh?).
Good Luck!
SELECT 'create index ' || substr(ut.table_name,1,20) || ROUND(sys.dbms_random.value*100)||'IDX ' || 'ON ' || ut.table_name || ' (' || ucc.column_name || ') ' || 'TABLESPACE ' || ut.TABLESPACE_NAME||'PK pctfree 10' ddl_string FROM USER_TABLES ut, USER_CONSTRAINTS uc, USER_CONS_COLUMNS ucc WHERE uc.constraint_type='R' AND ucc.constraint_name = uc.constraint_name AND ut.table_name = uc.table_name AND NVL(position,1) = 1 AND NOT EXISTS(SELECT 1 FROM USER_IND_COLUMNS uic WHERE uic.table_name=ucc.table_name AND ucc.column_name = uic.column_name AND uic.column_position=1) ORDER BY 1;
Tom
-- //www.freelists.org/webpage/oracle-l