标签:
目的:监控oracle索引的有效性,看索引有没有被使用。然后根据监控结果删除或者调整索引。
步骤:
1.监控指定索引
命令: alter index 索引名 monitoring usage; 如:alter index User_IDX1 monitoring usage;
2.查看索引监控是否生效
命令:select * from V$OBJECT_USAGE t where t.monitoring = ‘YES‘;
3.执行索引相关SQL
4.查看索引是否被使用
命令:select * from V$OBJECT_USAGE t where t.monitoring = ‘YES‘;
5.取消索引监控
命令: alter index 索引名 nomonitoring usage; 如:alter index User_IDX1 nomonitoring usage;
相关工具
生成指定表所有索引监控命令的SQL:
select ‘alter index ‘||index_name||‘ monitoring usage;‘ from user_indexes where table_name=upper(‘表名‘);
如:select ‘alter index ‘||index_name||‘ monitoring usage;‘ from user_indexes where table_name=upper(‘User‘);
标签:
原文地址:http://www.cnblogs.com/jacktang/p/4469179.html