点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
背景介绍
特点:
使用基本压缩,只有当数据是直接路径插入或更新记录(direct-path insert and updated )时才会发生压缩。 并且支持有线的数据类型和SQL操作。
建立测试表
create table t_compress1(a number,b number,c number) compress pctfree 0;

生成测试数据
insert /*+ append*/ into t_uncompress select
rownum,mod(rownum,10000),mod(rownum,3) from
all_objects,all_objects where rownum<300000;

直接路径插入
insert /*+ append*/ into t_compress1 select * from t_uncompress order by a;

普通方法插入
insert into t_compress4 select * from t_uncompress order by c;

查看各压缩列(order by)的压缩率
select table_name,round((blocks-EMPTY_BLOCKS)/(select
blocks-EMPTY_BLOCKS from user_tables where
table_name='T_UNCOMPRESS')*100,2) pct from user_tables where
table_name like '%T_COMPRESS%';

由此看出,order by(压缩列)的列不同会导致压缩率的不同,这里是B压缩列压缩率最高。
查看数据分布情况
select column_name,NUM_NULLS,NUM_DISTINCT,AVG_COL_LEN from user_tab_columns where table_name='T_UNCOMPRESS';

结论
o insert /*+ append * /
o create table as select
o direct path loads
o moves

本文作者:杨 浩(上海新炬王翦团队)
本文来源:“IT那活儿”公众号

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




