Question: How do I
find unindexed foreign key columns? I know that not having an
index on a foreign key can cause poor table join performance and I
want a script to detect foreign keys that do not have an index.
Yes, foreign key constraints that are not created with an
index can cause sub-optimal table join plans. See my
important notes on
foreign key indexing.
following script will detect all foreign key constraints
that are unindexed.
Note this in this example
script you will be promoted to provide the schema owner
column table_name format a30
column fk_columns format a30
column index_columns format a30
when b.table_name is null
end as status,
listagg(a.column_name, ',') within
group (order by a.position) fk_columns
a.owner = '&&schema_owner'
a.owner = b.owner
group (order by c.column_position) index_columns
like a.fk_columns || '%'
1 desc, 2;
For more complete scripts, see the
Oracle Training from Don Burleson
The best on site
training classes" are just a phone call away! You can get personalized Oracle training by Donald Burleson, right at your shop!
Burleson is the American Team
documentation was created as a support and Oracle training reference for use by our
DBA performance tuning consulting professionals.
Feel free to ask questions on our
considering using the services of an Oracle support expert should
independently investigate their credentials and experience, and not rely on
advertisements and self-proclaimed expertise. All legitimate Oracle experts
Oracle technology is changing and we
strive to update our BC Oracle support information. If you find an error
or have a suggestion for improving our content, we would appreciate your
and include the URL for the page.
Copyright © 1996 - 2020
All rights reserved by
is the registered trademark of Oracle Corporation.