Friday, September 28, 2007

How to find which indexes are used and which indexes are NOT used?

In Oracle10g we can easily see what indexes are used, when they are used and the context where they are used.

select
p.object_name c1,
p.operation c2,
p.options c3,
count(1) c4
from
dba_hist_sql_plan p,
dba_hist_sqlstat s
where
p.object_owner <> 'SYS'
and
p.operation like '%INDEX%' and
p.sql_id = s.sql_id
group by
p.object_name,
p.operation,
p.options
order by
1,2,3;

No comments: