当前位置:Gxlcms > 数据库问题 > Oracle 工具类 Sql 分析索引的 碎片率

Oracle 工具类 Sql 分析索引的 碎片率

时间:2021-07-01 10:21:17 帮助过:45人阅读

分析语句:
SQL>analyze index <index_name> validate structure online;

分析表:
analyze table tablename compute statistics;

analyze index indexname compute statistics;

 

查看索引碎片的情况:
SQL>select name,del_lf_rows_len,lf_rows_len,(del_lf_rows_len/lf_rows_len)*100 from index_stats;
索引碎片率:(del_lf_rows_len/lf_rows_len)*100
如果索引碎片率超过20%,oracle就会认为索引碎片已经非常严重,此时就需要对索引碎片进行整理。

 

 

2、索引碎片整理
索引碎片整理包括两种策略:
(1)重建索引(rebuild)
SQL>alter index <index_name> rebuild;
(2)压缩索引(coalesce)
SQL>alter index <index_name> coalesce;

 

oracle建议定期分析之后采用重建索引(rebuild)的策略。

 

Oracle 工具类 Sql 分析索引的 碎片率

标签:碎片整理   ping   div   tom   重建索引   rebuild   整理   style   orm   

人气教程排行