Script #69
oracle
Performanceread-onlyMin Version: 12cFind 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.
Other ORACLE Diagnostic Scripts
View All (100)#61Performance
Oracle Active Sessions and Wait Events
Lists active user sessions with the running SQL_ID and wait event. Shows the live picture during performance issues.
View Script
#62Locking
Find Blocking Sessions in Oracle
Shows sessions that make others wait, with wait times. Identifies the root session to terminate in lock incidents.
View Script
#63Storage
Oracle Tablespace Usage Including Autoextend
Calculates tablespace usage against the real maximum, honoring autoextend limits. Catches space errors like ORA-01653 before they happen.
View Script
#64Performance
Top 20 Most Expensive Oracle SQL with v$sqlstats
Shows costliest SQL by elapsed time with executions, CPU and I/O. Tells you which SQL_ID to investigate for tuning.
View Script