rebuild索引,違背直覺得實驗結果
Prompt ================================
prompt
prompt Test 1.
prompt Rebuild before adding extra data
prompt
prompt ================================
prompt
prompt Test 1.
prompt Rebuild before adding extra data
prompt
prompt ================================
table t1(n1 number(38));
Table created.
index i1 on t1(n1);
Index created.
PL/SQL procedure successfully completed.
>
2 for i in 1..400000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
2 for i in 1..400000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
PL/SQL procedure successfully completed.
index i1 validate structure;
Index analyzed.
2 'Leaf blocks before rebuild: ' || lf_blks leaf_blocks
3 from index_stats;
Leaf
Blks
--------------------------------------------------------------------
Leaf blocks before rebuild: 1472
Blks
--------------------------------------------------------------------
Leaf blocks before rebuild: 1472
1 row selected.
index i1 rebuild pctfree 10;
Index altered.
index i1 validate structure;
Index analyzed.
2 'Leaf blocks immediately after rebuild: ' || lf_blks leaf_blocks
3 from index_stats;
Leaf
Blks
-------------------------------------------------------------------------------
Leaf blocks immediately after rebuild: 1114
Blks
-------------------------------------------------------------------------------
Leaf blocks immediately after rebuild: 1114
1 row selected.
>
2 for i in 1..100000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
PL/SQL procedure successfully completed.
>
>
index i1 validate structure;
>
index i1 validate structure;
Index analyzed.
2 'Leaf blocks after further processing: ' || lf_blks leaf_blocks
3 from index_stats;
Leaf
Blks
------------------------------------------------------------------------------
Leaf blocks after further processing: 2227
Blks
------------------------------------------------------------------------------
Leaf blocks after further processing: 2227
1 row selected.
prompt
Prompt ================================
prompt
prompt Test 2:
prompt Without rebuilding.
prompt
prompt ================================
>
table t1;
Table dropped.
2 begin execute immediate 'purge recyclebin';
3 exception when others then null;
4 end;
5 end;
6 /
PL/SQL procedure successfully completed.
>
table t1(n1 number(38));
table t1(n1 number(38));
Table created.
index i1 on t1(n1);
Index created.
PL/SQL procedure successfully completed.
>
2 for i in 1..400000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
2 for i in 1..400000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
PL/SQL procedure successfully completed.
2 for i in 1..100000 loop
3 insert into t1 values(
4 trunc(power(10,14) * dbms_random.value)
5 );
6 commit;
7 end loop;
8 end;
9 .
PL/SQL procedure successfully completed.
index i1 validate structure;
Index analyzed.
2 'Leaf blocks with no intermediate rebuild: ' || lf_blks leaf_blocks
3 from index_stats;
Leaf
Blks
----------------------------------------------------------------------------------
Leaf blocks with no intermediate rebuild: 1777
Blks
----------------------------------------------------------------------------------
Leaf blocks with no intermediate rebuild: 1777
1 row selected.
index i1 rebuild pctfree 10;
Index altered.
index i1 validate structure;
Index analyzed.
2 'Leaf blocks at end of test: ' || lf_blks leaf_blocks
3 from index_stats;
Leaf
Blks
--------------------------------------------------------------------
Leaf blocks at end of test: 1393
Blks
--------------------------------------------------------------------
Leaf blocks at end of test: 1393
1 row selected.
實驗的結果似乎違背的直覺。
第一個測試案例裡:
1)我們先進行了一次資料的集中插入。完成後,索引的大小是1472個block.這個操作非常接近我們現實的情況。
2)然後我們重建了索引,索引大小降低到1114。
3)我們重新往表裡插入了一批資料。這個時候索引的大小是2227。
第二個測試案例裡:
1)跟案例一一樣,進行了一次資料的集中插入。
2)不重建索引,直接再次進行一次資料插入,同案例一里面的步驟3.這個時候索引的大小是1777。竟然比案例一里的2227低。
1)跟案例一一樣,進行了一次資料的集中插入。
2)不重建索引,直接再次進行一次資料插入,同案例一里面的步驟3.這個時候索引的大小是1777。竟然比案例一里的2227低。
這個違背直覺的實驗,我想主要是因為索引重建後,導致索引的分裂比重建前更加的頻繁。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-714000/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 增加深度,加速神經網路優化?這是一份反直覺的實驗結果神經網路優化
- MSSQL Rebuild(重建)索引SQLRebuild索引
- 聊聊索引Index Rebuild和Rebuild Online(下)索引IndexRebuild
- 索引rebuild和rebuild online時要慎重索引Rebuild
- 聊聊索引Index Rebuild和Rebuild Online(上)索引IndexRebuild
- 轉個分割槽表Local索引Rebuild的總結索引Rebuild
- 選出需要rebuild的索引Rebuild索引
- 索引rebuild和rebuild online時要慎重(轉載)索引Rebuild
- Mozilla 公佈 DNS over HTTPS 實驗結果DNSHTTP
- oracle索引分類rebuild案例集Oracle索引Rebuild
- 索引是如何定期rebuild的(zt)索引Rebuild
- 不要過於自信於經驗和直覺!
- 關於分割槽表Local索引Rebuild的一些總結索引Rebuild
- 分享一個關於Cookie做的實驗結果Cookie
- 【實驗】【索引壓縮】索引壓縮演示及優缺點總結索引
- 實驗3.直連靜態路由實驗路由
- 我覺得eventbus最難實現
- rebuild分割槽表分割槽索引的方法Rebuild索引
- 檢查是否存在truncate或者rebuild的索引Rebuild索引
- 關於索引是否該rebuild的問題索引Rebuild
- 加快建立索引(create / rebuild index) 的幾點索引RebuildIndex
- filebeat輸出結果到elasticsearch的多個索引Elasticsearch索引
- 資料庫索引背後的資料結構資料庫索引資料結構
- mysql索引使用經驗總結MySql索引
- 以太坊實踐經驗之《eth.blockNumber結果為0》BloC
- 自然語言處理第一次實驗結果自然語言處理
- HttpRunner 的結果校驗器優化HTTP優化
- rebuild online索引遇到ora-1450Rebuild索引
- create index , rebuild index troubleshooting 索引故障解決IndexRebuild索引
- ORA-08104 索引online rebuild索引Rebuild
- 索引rebuild online失敗後處理索引Rebuild
- 測試sql server全文索引,結果遇到問題SQLServer索引
- CHAR型別函式索引導致結果錯誤型別函式索引
- 視覺化經典模型的對比實驗總結視覺化模型
- Tableau視覺化結果的優化小技巧(二)視覺化優化
- shrink 與rebuild對索引高度的影響對比Rebuild索引
- 個人覺得實用的Python姿勢Python
- MySQL 為什麼全文索引查中文找不結果MySql索引