Orcle 12c 新特性---支持高级索引压缩

博客介绍了高级索引压缩的优势,它适用于多种索引,能显著提高压缩率且访问高效。还进行了相关实验,实验前要求数据库版本为12.1.0及以上,包含创建表并插入数据、创建普通索引、将已有索引重建为高级压缩索引以及直接创建高级压缩索引等步骤,并查看索引大小。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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   -大小不变
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值