? ? 對(duì)index進(jìn)行分析,index_stats 表很有用。下面例子就結(jié)合index相關(guān)操作及 index_stats 的使用,對(duì)index進(jìn)行分析。
?
SQL> select count(*) from index_stats;
COUNT(*)
----------
0
SQL> desc t
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER(38)
SCN NUMBER
SQL> create index t_idx on t(id);
Index created.
SQL> select * from t;
ID SCN
---------- ----------
1 576757
2 577958
3 578038
4 603361
5 603575
5 3
5 3
7 rows selected.
?
SQL> analyze index t_idx validate structure;
Index analyzed.
SQL> select count(*) from index_stats;
COUNT(*)
----------
1
SQL> select height,name,lf_rows,del_lf_rows from index_stats;
HEIGHT NAME LF_ROWS DEL_LF_ROWS
---------- ------------------------------ ---------- -----------
1 ? ? ? ? ?T_IDX ? ? ?7 ? ? ? ? ? 0
?
?
SQL> delete from t where id=5;
3 rows deleted.
SQL> commit;
?
SQL> analyze index t_idx validate structure;
Index analyzed.
SQL> select height,name,lf_rows,del_lf_rows from index_stats;
HEIGHT NAME LF_ROWS DEL_LF_ROWS
---------- ------------------------------ ---------- -----------
1 ? ? ? ? ? T_IDX ? ? ? ?7 ? ? ? ? ? ? 3
?
SQL> alter index t_idx rebuild;
Index altered.
SQL> select height,name,lf_rows,del_lf_rows from index_stats;
no rows selected
?
SQL> analyze index t_idx validate structure;
Index analyzed.
SQL> select height,name,lf_rows,del_lf_rows from index_stats;
HEIGHT NAME LF_ROWS DEL_LF_ROWS
---------- ------------------------------ ---------- -----------
1 ? ? ? ? ? ?T_IDX ? ? ? ?4 ? ? ? ? ?0
SQL>
?
?
說(shuō)明:
1.如果一個(gè)index的LF_ROWS與DEL_LF_ROWS比例超過(guò)15%,就需要rebulid了。
2.一般情況下,rebuild對(duì)自增長(zhǎng)字段被刪除列比較有用。
3.如果一個(gè)表批量導(dǎo)入大數(shù)據(jù),先刪除index,導(dǎo)入數(shù)據(jù)后,再create index;這樣速度比較高。
?
?
?
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
