How to check on Index actual usage?
============================
ALTER INDEX MY_INDEX_IX1 MONITORING USAGE;
ALTER INDEX MY_INDEX_IX2 MONITORING USAGE;
SELECT table_name,
index_name,
used,
start_monitoring,
end_monitoring
FROM v$object_usage
WHERE table_name = UPPER('&1')
AND index_name = IN ('MY_INDEX_IX1', 'MY_INDEX_IX2')
ALTER INDEX MY_INDEX_IX1 NOMONITORING USAGE;
ALTER INDEX MY_INDEX_IX2 NOMONITORING USAGE;
In case of ORA-ORA-00054: resource busy and acquire with NOWAIT specified do:
ALTER SESSION SET DDL_LOCK_TIMEOUT = 600;
and then again
ALTER INDEX MY_INDEX_IX1 MONITORING USAGE;
Make Index Unusable/Invisible.
Making an Index Unusable
When you make an index unusable, it is ignored by the optimizer and is not maintained by DML.
You must rebuild or drop and re-create an unusable index before using it.
Index can be set to be unusable, in Table or in Partition level.
ALTER INDEX emp_email_uk UNUSABLE;
ALTER INDEX i_emp_ename MODIFY PARTITION p2_i_emp_ename UNUSABLE;
Making an Index Invisible
An invisible index is ignored by the optimizer unless you explicitly set the OPTIMIZER_USE_INVISIBLE_INDEXES initialization parameter to TRUE at the session or system level.
It is still maintained by
Making an index invisible is an alternative to making it unusable or dropping it.
Index can be made Invisible only in Table level.
You cannot make an individual index partition invisible.
To make an index invisible: ALTER INDEX index INVISIBLE;
To make an invisible index visible again: ALTER INDEX index VISIBLE;
Check Index current status:
SELECT index_name, visibility, status
FROM USER_INDEXES;
For regular index, status would be VALID
For unusable index, status would be UNUSABLE
Appendix
Oracle Documentation: Altering Indexes
SELECT table_name,
index_name,
used,
start_monitoring,
end_monitoring
FROM v$object_usage
WHERE table_name = UPPER('&1')
AND index_name = IN ('MY_INDEX_IX1', 'MY_INDEX_IX2')
ALTER INDEX MY_INDEX_IX1 NOMONITORING USAGE;
ALTER INDEX MY_INDEX_IX2 NOMONITORING USAGE;
In case of ORA-ORA-00054: resource busy and acquire with NOWAIT specified do:
ALTER SESSION SET DDL_LOCK_TIMEOUT = 600;
and then again
ALTER INDEX MY_INDEX_IX1 MONITORING USAGE;
Make Index Unusable/Invisible.
Making an Index Unusable
When you make an index unusable, it is ignored by the optimizer and is not maintained by DML.
You must rebuild or drop and re-create an unusable index before using it.
Index can be set to be unusable, in Table or in Partition level.
ALTER INDEX emp_email_uk UNUSABLE;
ALTER INDEX i_emp_ename MODIFY PARTITION p2_i_emp_ename UNUSABLE;
Making an Index Invisible
An invisible index is ignored by the optimizer unless you explicitly set the OPTIMIZER_USE_INVISIBLE_INDEXES initialization parameter to TRUE at the session or system level.
It is still maintained by
Making an index invisible is an alternative to making it unusable or dropping it.
Index can be made Invisible only in Table level.
You cannot make an individual index partition invisible.
To make an index invisible: ALTER INDEX index INVISIBLE;
To make an invisible index visible again: ALTER INDEX index VISIBLE;
Check Index current status:
SELECT index_name, visibility, status
FROM USER_INDEXES;
For regular index, status would be VALID
For unusable index, status would be UNUSABLE
Appendix
Oracle Documentation: Altering Indexes