ORACLE EHCC(exadata hybrid columnar compression)_weixin_30387799的博客-程序员宅基地

技术标签: 数据库  

目录:

  1. 简介

  2. 压缩方式及压缩比

  3. 压缩哪些数据

  4. 可能有用的脚本

 

一、简介

  EHCC(Exadata Hybrid Columnar Compression),是Oralce 数据库在12C 中新增加的压缩方式,除了具有压缩数据的功能外,还有一个特点就是列式存储。

  也就是说,当通过EHCC方式对数据库所有数据进行压缩后,从数据存储方式上来看,可以理解成一个列式存储数据库。那么列式存储在经分系统中的高效在很多专门的列式数据库中已经体现得非常明显。这里不再拿数据说事。

  这也是Oracle 占领市场的又一尖刀。Oracle 说了,你有的,我有。你没有的,我也有,哪怕我现在没有,也很快会有!

  同时,我们可以将EHCC理解为磁盘版的 in-memory 。

  与传统的压缩方式对比,之前的压缩方式更适用于OLTP系统。而EHCC则更适合于DSS 系统,及部分OLAP系统业务。

二、压缩方式及压缩比

  表1:压缩方式及压缩比

压缩方式 压缩比
BASE   65%
FOR OLTP 62%
Qery High 95%
Qery Low 89%
Archive High 97.5%
Archive Low 95%

  2.1. 压缩比

     先说明下压缩比的概念: (1-压缩后的空间/未压缩前的空间)*100% 。 即为压缩掉的空间占原空间的比例。

     比如一张未经压缩的表的数据量为20G .那么 base 方式压缩,压缩比为65%,也就是说会压缩掉20G*65%=13G. 压缩掉13G,压缩完后,该表占用空间为7G.

     1.  BASE  与 OLTP   压缩效率差不多,而它们之间的那点差别,可能是因为BASE方式表的PCT_FREE 为0,而OLTP 为10%。
     2. QUERY LOW       相对压缩率不高,采用LZO压缩算法,但是也比ORACLE自带的压缩效果高很多
     3. QUERY HIGH和ARCHIVE LOW     都是使用ZLIB压缩算法。因此压缩几乎是相等的。
     4. ARCHIVE HIGH    采用Bzip2压缩算法实现 ,压缩比极高,

 

     EHCC特性支持普通的数据表和分区

    •  支持分区

      除普通堆表外,还支持对单个分区进行压缩。

        如:  

create table test_ehcc_compression (id)
partition by range (id)
partition p1 values less than (100) nocompress,
partition p2 values less than (200) compress for archive low,
partition p3 values less than (300) compress for query high,
partition p4 values less than (400) compress for query low);

 

三、压缩哪些数据

  需要注意的一点是,对于启用了EHCC的表,并不是将插入表的所有数据都会进行EHCC的方式进行压缩。而是只有通过特定的方式插入表的数据才会处理。

 

  • 对于单行的insert 语句:新添加的行贿通过OLTP方式被压缩。
  • 对于update语句:修改会被转换为delete 和insert。
  • 对于delete 语句:删除只会在CU头当中对应的位上将该行标识成无效
  • alter 语句启用EHCC时,原有数据不压缩,只处理新数据。

  对于使用了EHCC的表,只有在使用以下的方式向表当中加载数据时才会触发数据压缩。

  •     直接路径insert语句
  •     并行的DML语句
  •     直接路径sqlloader
  •     CTAS(create table as select)

四、可能有用的脚本

1. 进行数据压缩比对比的SQL脚本

  

-- 准备初始数据
create table Test_objects as select * from dba_objects;
 
begin
for i in 1..100000 loop
   insert into Test_objects select * from dba_objects;
  commit;
 end loop;
end;
 /
 
-- 查看初始数据量
select segment_name 
,      segment_type 
,      round(sum(bytes)/1024/1024/1024,2) size_gb
from dba_segments
where segment_name ='TEST_OBJECTS'
group by segment_name,segment_type
order by 1;

-- 生成不同压缩方式的表
create table test_objects_base compress nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_oltp compress for oltp nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_olap compress for olap nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_base compress for query high parallel 10 nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_base compress for query low parallel 10 nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_base compress for archive high parallel 10 nologging select/*+ parallel(a,10) */ from Test_objects a;
create table test_objects_base compress for archive low parallel 10 nologging select/*+ parallel(a,10) */ from Test_objects a;

-- 取得压缩前后各表的占用空间及各自的压缩方式
select s.owner,segment_name,s.bytes/(1024*1024*1024) t_size,compress_for 
from dba_segments s,dba_tables t
where s.owner=t.owner and t.table_name=s.segment_name 
and s.owner='&owner' and t.table_name like 'TEST_OBJECTS%';

 

  2. 压缩表之前预估压缩比的脚本

declare
 v_blkcnt_cmp     pls_integer;
 v_blkcnt_uncmp   pls_integer;
 v_row_cmp        pls_integer;
 v_row_uncmp      pls_integer;
 v_cmp_ratio      number;
 v_comptype_str   varchar2(60);
begin
 dbms_compression.get_compression_ratio(
 scratchtbsname   => upper('&ScratchTBS'),      
 ownname          => user,           
 tabname          => upper('&TableName'),   
 partname         => NULL,           
 comptype         => dbms_compression.comp_for_query_high,    
 blkcnt_cmp       => v_blkcnt_cmp,    
 blkcnt_uncmp     => v_blkcnt_uncmp,  
 row_cmp          => v_row_cmp,    
 row_uncmp        => v_row_uncmp,  
 cmp_ratio        => v_cmp_ratio,  
 comptype_str     => v_comptype_str);
 dbms_output.put_line('Estimated Compression Ratio: '||to_char(v_cmp_ratio));
 dbms_output.put_line('Blocks used by compressed sample: '||to_char(v_blkcnt_cmp));
 dbms_output.put_line('Blocks used by uncompressed sample: '||to_char(v_blkcnt_uncmp));
end;
/

 

转载于:https://www.cnblogs.com/halberd-lee/p/8583210.html

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_30387799/article/details/99220847

智能推荐

SAP CO Report_乐期无许的博客-程序员宅基地

SAP CO Report  1、成本与收入会计报表S_ALR_87013598 成本要素: 按业务部门细分S_ALR_87013599 成本要素: 按功能范围细分S_ALR_87013600 成本要素: 列中的对象类2、凭证显示KSB5 管理会计凭证: 实际成本KALR 统驭分类帐: CO 行项目3...

linux如何查看网口ip_Linux 常用命令_weixin_39846898的博客-程序员宅基地

阅读文本大概需要 3 分钟。自己开始接触 Linux「Ubuntu」应该是在大学期间, 接触 Unix「Mac OSX」是在工作后的第一份工作,吭哧吭哧的用了好几年的 Linux,强行此文,自己总结了目前经常用到的几个命令,希望给 Linux 用户提供帮助。如果没有 Linux 的,也可以在 win10 的 Store 上面直接安装 Ubuntu,win7 用户也可以安装 GIT 或者 Cygwi...

程序员必背单词_荚小白的博客-程序员宅基地

-- =======================A=============================abstract 抽象的abstract base class (ABC)抽象基类abstract class 抽象类abstraction 抽象、抽象物、抽象性access 存取、访问access function 访问函数access level访问级别account...

【Error】git push时出现 fatal: unable to access ‘xxx‘: OpenSSL SSL_read: Connection was reset_MangoloD的博客-程序员宅基地

今天在使用git的时候出现了点小问题,即git push origin masterfatal: unable to access 'https://github.com/MangoloD/Attention.git/': OpenSSL SSL_read: Connection was reset, errno 10054可以看到我在使用git push命令时,报错啦产生原因:一般是这是因为服务器的SSL证书没有经过第三方机构的签署,所以才报错查看了网上的解决方法,记录一下:方案一g

开源整理:酷酷的Android Loading动画,让用户摆脱无聊等待_技术视界的博客-程序员宅基地

一个出色的应用常常会用心打磨各种交互细节,例如为了能够让用户在某些耗时操作的等待过程中不要感到那么无聊,加上一个有趣的Loading动画效果将会是一个不错的选择。今天就为大家推荐Github上几个效果比较酷的优质开源项目,让你的用户可以打发无聊的等待时间,体验更上一层楼。AVLoadingIndicatorViewhttps://github.com/81813780/AVLoadingIndic

05-树9 Huffman Codes_王寒寒的博客-程序员宅基地

05-树9 Huffman Codes来自:PTA_数据结构_Huffman CodesIn 1953, David A. Huffman published his paper “A Method for the Construction of Minimum-Redundancy Codes”, and hence printed his name in the history of co...

随便推点

JavaCV异常:avio_open2 error() error -138: Could not open ‘null‘的解决方法_banmajio的博客-程序员宅基地

JvaCV报错avio_open2 error() error -138: Could not open 'null'的解决方法问题分析解决方法项目码云(Gitee)地址:https://gitee.com/banmajio/RTSPtoRTMP项目github地址:https://github.com/banmajio/RTSPtoRTMP个人博客:banmajio’s blogj...

Python:tkinter模块_tkinter导入_yokii_的博客-程序员宅基地

tkinter 组件 组件 说明 Button 按钮控件;在程序中显示按钮。 Canvas 画布控件;显示图形元素如线条或文本 Checkbutton 多选框控件;用于在程序中提供多项选择框 Entry 输入控件;用于显示简单的文本...

[渗透测试笔记] 33.CobaltStrike基础_H4ppyD0g的博客-程序员宅基地

文章目录CobaltStrike介绍环境搭建在客户端启动`cobaltstrike.exe`![在这里插入图片描述](https://img-blog.csdnimg.cn/45dfd52be1fe42adb6a4b6c940908900.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE3MjI2MQ==,size_16,

运行项目编译报错_du_90的博客-程序员宅基地

在编译项目的时候XIB报这种错误Internal error. Please file a bug at bugreport.apple.com and attach “/var/folders/2v/krsnqt7j7bdfpg8zg_x0cszc0000gn/T/IB-agent-diagnostics_2015-11-16_09-11-23_017000”.开始的时候以为是动了xib文件就

mac下安装mbstring_你是我的绝笔的博客-程序员宅基地

今天写php一个查询模块,需要从数据库读取一段内容,但是不要太多。只要截取部分即可,于是想到用mb_substr函数,但是发现不支持这个函数,于是去网上找教程,在http://stackoverflow.com/questions/4787403/missing-mbstring-php-extension-when-installing-phpmyadmin-on-mac中找到

Valine评论系统不能使用_画江湖之不浪人的博客-程序员宅基地

1、Valine 评论系统不能使用这几天发现 Valine 评论系统不见了,没法使用啦,发现原来是themes / next1 / layout / _third-party / comments / valine.swig这个文件网页找不到的问题2、原因官方也给了说法,是因为 leancloud.cn 以及 ..lncld.net 域名不能解析了,官方说明链接 见图3、解决方案我...

推荐文章

热门文章

相关标签