You can use the index monitoring feature to check if indexes are used by an application or not. If u set the MONITORING USAGE property for an index, you can query the v$object_usage to see if the index is being used or not. Here is an example:
sys@BBK> CREATE INDEX t1_idx ON t1(c1);
Index created.
sys@BBK> ALTER INDEX t1_idx MONITORING USAGE;
Index altered.
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX YES NO
sys@BBK> SELECT * FROM t1 WHERE c1 = 1;
no rows selected
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX YES YES
sys@BBK> ALTER INDEX t1_idx NOMONITORING USAGE;
Index altered.
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX NO YES
sys@BBK>
OR use the following way;
sql> set autot on exp
sql> SELECT * FROM t1 WHERE c1 = 1;
sys@BBK> CREATE INDEX t1_idx ON t1(c1);
Index created.
sys@BBK> ALTER INDEX t1_idx MONITORING USAGE;
Index altered.
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX YES NO
sys@BBK> SELECT * FROM t1 WHERE c1 = 1;
no rows selected
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX YES YES
sys@BBK> ALTER INDEX t1_idx NOMONITORING USAGE;
Index altered.
sys@BBK> SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MON USE
------------------------------ ------------------------------ --- ---
T1 T1_IDX NO YES
sys@BBK>
OR use the following way;
sql> set autot on exp
sql> SELECT * FROM t1 WHERE c1 = 1;
本文介绍了一种在数据库中监控索引使用情况的方法。通过设置索引的 MONITORING USAGE 属性,可以查询 v$object_usage 视图来检查索引是否被应用程序使用。文章通过示例展示了如何创建和修改索引来启用或禁用此监控功能。
715

被折叠的 条评论
为什么被折叠?



