壓縮索引

創建壓縮索引

從串聯索引中去掉冗餘

壓縮索引特徵:

每個條目分爲兩項:前綴和後綴

前綴:建立在串聯索引的前幾列,這些列有許多值重複

後綴:索引鍵後幾列,是前綴索引所在索引中唯一部分。

create table ind_test as select * from all_objects;
drop table id_stats;
create table id_stats as select  'compress   33333' what ,t.* from index_stats t where 1=0;

drop index ind_compress;
create index ind_compress on ind_test(owner,object_type,object_name);
analyze index ind_compress validate structure;
analyze index ind_compress compute statistics;
insert into id_stats select 'compress 0',t.* from index_stats t ;

drop index ind_compress;
create index ind_compress on ind_test(owner,object_type,object_name) compress 1;
analyze index ind_compress validate structure;
analyze index ind_compress compute statistics;
insert into id_stats select 'compress 1',t.* from index_stats t ;

drop index ind_compress;
create index ind_compress on ind_test(owner,object_type,object_name) compress 2;
analyze index ind_compress validate structure;
analyze index ind_compress compute statistics;
insert into id_stats select 'compress 2',t.* from index_stats t ;

drop index ind_compress;
create index ind_compress on ind_test(owner,object_type,object_name) compress 3;
analyze index ind_compress validate structure;
analyze index ind_compress compute statistics;
insert into id_stats select 'compress 3',t.* from index_stats t ;

官網上說是分析後壓縮節省空間:但是我認爲是在最佳壓縮方案下,在當前基礎上還能節省空間

壓縮會增加CPU計算,不光光維護還有查詢也是的。這需要開發者在IO和CPU計算做出一個權衡。

利用壓縮能夠減少該索引的緩衝塊的個數,從而減少IO次數,增加CPU次數,增加對索引競爭

如果當前大量佔用CPU時間,使用索引壓縮會適得其反,降低查詢速度

如果當前大量IO,使用壓縮索引鍵會提高性能

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章