dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Scripts Library/oracle/#69
Script #69
oracle
Performanceread-onlyMin Version: 12c

Find Unused Indexes in Oracle (DBA_INDEX_USAGE)

Lists indexes not used by queries, with access counts. Produces drop candidates to reduce write cost.

#index-usage#v$object_usage#cleanup
oracle · sql
-- 12.2+ : DBA_INDEX_USAGE
SELECT i.owner, i.index_name, i.table_name, i.index_type,
       NVL(u.total_access_count, 0) AS total_access_count, u.last_used
FROM   dba_indexes i
LEFT JOIN dba_index_usage u ON u.owner = i.owner AND u.name = i.index_name
WHERE  i.owner NOT IN ('SYS','SYSTEM')
  AND  i.uniqueness = 'NONUNIQUE'
  AND  NVL(u.total_access_count, 0) = 0
ORDER  BY i.owner, i.table_name;
Operational Notes & Remediation Guidance

Enable index monitoring with `ALTER INDEX ... MONITORING USAGE;` or inspect `DBA_INDEX_USAGE` in Oracle 12c+.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 12c).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.