How to find index is fragmented?
First analyze index
1. If del_lf_rows/lf_rows is > .2 then index should be rebuild.
2. If height is 4 then index should be rebuild.
3. If lf_rows is lower than lf_blks then index should be rebuild.
There are two way to remove fragmentation.
1. index coalesce
2. index rebuild
What is difference between coalesce and rebuild please go through below link for more details - CLICK
Note: If any DML statement is running on base table then we have to use ONLINE keyword with index rebuilding.
First analyze index
Then query INDEX_STATS view
SQL>analyze index INDEX_NAME validate structure;
1. If del_lf_rows/lf_rows is > .2 then index should be rebuild.
2. If height is 4 then index should be rebuild.
3. If lf_rows is lower than lf_blks then index should be rebuild.
How to remove index fragmentation?
SQL> column status format a10
SQL> select trunc((del_lf_rows/lf_rows)*100,2)||'%' "status" from index_stats;
status
----------
22.83%
There are two way to remove fragmentation.
1. index coalesce
2. index rebuild
What is difference between coalesce and rebuild please go through below link for more details - CLICK
SQL> alter index IDX_OBJ_ID coalesce;
SQL> alter index IDX_OBJ_ID rebuild;
SQL> alter index IDX_OBJ_ID rebuild online;
Note: If any DML statement is running on base table then we have to use ONLINE keyword with index rebuilding.
SQL> analyze index idx_obj_id validate structure;
Index analyzed.
SQL> select trunc((del_lf_rows/lf_rows)*100,2)||'%' "status" from index_stats;
status
-------
41.85%
SQL> alter index IDX_OBJ_ID rebuild online;
Index altered.
SQL> analyze index idx_obj_id validate structure;
Index analyzed.
SQL> select trunc((del_lf_rows/lf_rows)*100,2)||'%' "status" from index_stats;
status
--------
0%
No comments:
Post a Comment