1 说明
Advanced Index Compression works well on all supported indexes, including those indexes that are not good candidates for the existing prefix compression feature; including indexes with no, or few, duplicate values in the leading columns of the index.
高级索引压缩在所有受支持的索引上使用都非常好,包括那些不适合现有前缀压缩特性的索引;
在索引的前导列中包含没有或很少重复值的索引。
Advanced Index Compression improves the compression ratios significantly while still providing efficient access to the index.
高级索引压缩大大提高了压缩率,同时仍然访问索引很有效率。
2 实验
在启用高级索引压缩之前,数据库必须是12.1.0以及以上版本。压缩级别:LOW,HIGH
2.1 创建表并插入数据
SQL> conn lei/lei@lei1;
Connected.
SQL> create table cndba_t as select * from dba_objects;
Table created.
SQL> insert into cndba_t select * from cndba_t;
81053 rows created.
SQL> /
162106 rows created.
2.2 创建普通索引
SQL> create index cndba_ind on cndba_t(object_name);
Index created.
–查看索引大小
SQL> select segment_name ,sum(bytes)/1024/1024
from user_segments
where segment_type ='INDEX'
and SEGMENT_NAME ='CNDBA_IND'
group by segment_name; 2 3 4 5
SEGMENT_NAME SUM(BYTES)/1024/1024
------------------ --------------------
CNDBA_IND 17 --大小为17M
2.2.1 重建已有索引为高级压缩索引
现在将cndba_ind索引重建为高级压缩索引
SQL> ALTER INDEX CNDBA_IND REBUILD COMPRESS ADVANCED LOW;
Index altered.
–再次查看索引大小
SQL> select segment_name ,sum(bytes)/1024/1024
from user_segments
where segment_type ='INDEX'
and SEGMENT_NAME ='CNDBA_IND'
group by segment_name; 2 3 4 5
SEGMENT_NAME SUM(BYTES)/1024/1024
------------------ --------------------
CNDBA_IND 8 --大小为8M,可以看到几乎减少了一半的大小。
2.3 创建高级压缩索引
SQL> CREATE INDEX CNDBA_IND ON CNDBA_T(object_name) COMPRESS ADVANCED LOW;
Index created.
–查看索引大小
SQL> select segment_name ,sum(bytes)/1024/1024
from user_segments
where segment_type ='INDEX'
and SEGMENT_NAME ='CNDBA_IND'
group by segment_name; 2 3 4 5
SEGMENT_NAME SUM(BYTES)/1024/1024
------------------ --------------------
CNDBA_IND 8 -大小不变