oracle 对索引进行监控与分析

查看表索引信息需要用到dba_indexes, dba_ind_columns,查看表索引列信息,包括复合索引的脚本:

索引列column_names以,分隔,需要指定表名与表的所有者信息。

翻了几页书,做一下笔记哦!

发现多余的索引有两种方式
1.根据原理来判断
  考虑复合索引,根据复合索引的前缀性与选择性,分析表字段的记录分布情况,对复合索引进行整合。
2.使用oracle的监控特性
alter index <index_name> monitoring usage; --对index_name开启监控
alter index <index_name> nomonitoring usage; --对index_name取消监控
select * from v$object_usage; --查询索引是否被使用

由USED=NO可知,idx_t_created索引没有被使用。

以上可以看出idx_t_created索引已经被使用了。

索引碎片分析与整理
建议每周监测一次索引的碎片情况,根据情况制定索引的重建频率以提高索引使用效率。
SQL> analyze index <index_name> validate structure;
SQL> select name,del_lf_rows_len,lf_rows_len,(del_lf_rows_len/lf_rows_len)*100 from index_stats;
索引碎片率(%) = (被删除的索引长度/索引总长)*100
SQL> alter index <索引名> rebuild;
SQL> alter index <索引名> coalesce;

1.如果索引的叶子行的碎片超过20%,考虑对索引进行重建。
alter index 用户名.索引名 rebuild  tablespace 表空间名  storage(initial 初始值 next 扩展值)  nologging
重建索引时要注意以下几点:
a.如果不指定tablespace名,索引将建在用户的默认表空间。
b.如果不指定nologging,将会写日志,导致速度变慢。由于索引的重建没有恢复的必要,所以,可以不写日志。
c.如果出现资源忙,表明有进程正在使用该索引,等待一会再提交。

2.如果出于空间或其他考虑,不能重建索引,可以整理索引。
alter index用户名.索引名 coalesce

Use the rebuild_clause to re-create an existing index or one of its partitions or subpartitions.If index is marked UNUSABLE, a successful rebuild will mark it USABLE. For a function-based index, this clause also enables the index. If the function on which the index is based does not exist, the rebuild statement will fail.

SpecifyCOALESCE to instruct Oracle Database to merge the contents of index blocks where possible to free blocks for reuse.


http://www.itpub.net/viewthread.php?tid=1368530


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值