无用索引

有时候我们需要检查是否存在无用的一些索引,因此可以通过下面方法得到

1.9i以后监控索引使用情况
alter index <INDEX_NAME> monitoring usage;
...
一个月后
select * from v$object_usage;

其中used字段为Y的,表示用过,但是不回记录使用次数,得到这个数据,后面的就随便你了,比如

我要把占用空间比较大的而且没有用过的索引找到

select segment_name,bytes/1048576 from user_segments where segment_name in
(select index_name from v$object_usage where used ='NO') and bytes/1048576>100 ;

然后去掉监控
alter index <INDEX_NAME> nomonitoring usage;


2.10g以后,通过awr报告相关历史数据,查询一段时间内用过的select distinct b.object_owner, b.object_name
 
from dba_hist_snapshot a, dba_hist_sql_plan b, dba_hist_sqlstat c
where a.snap_id = c.snap_id
and b.sql_id=c.sql_id
and b.object_type = 'INDEX' and object_owner='TXW0755_006'
group by  b.object_owner, b.object_name ;

不过这种方法有一定限制,因为11G里面默认的AWR报告是保存8天的数据,因此最后把AWR报告修改为一个月,然后查看,这样得到的数据就比较准确了。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值