11g引入了大量compress相关的特性,其中之一便是dbms_compression包;GET_COMPRESSION_RATIO函数可以帮助我们了解压缩某个表后各种可能的影响。换而言之,这个函数可以让我们在具体实施表压缩技术或者测试前,对于压缩后的效果能有一个基本的印象。该包在11gr2中被首次引入,故而使用之前版本的包括11gr1都无缘得用。其次除OLTP压缩模式之外的柱形混合压缩只能在基于Exdata存储的表空间上实现。使用DBMS_COMPRESSION包获取的相关压缩信息是十分准确的,因为在评估过程中Oracle通过实际采样并建立模型表以尽可能还原逼真的数据。 我们可以通过trace来分析其评估过程中的具体操作,可以分成2步: 1. 建立原表的样本表,其采样值基于原表的大小:

SQL> create table samp_dss_nation tablespace SCRATCH as select * from dss_nation sample block (50);Table created.

2. 基于采用表建立对应压缩类型的模型表:

SQL> create table model_dss_nation tablespace SCRATCH compress for query high as select * from samp_dss_nation;
create table model_dss_nation tablespace SCRATCH compress for query high as select * from samp_dss_nation
*
ERROR at line 1:
ORA-64307: hybrid columnar compression is only supported in tablespaces
residing on Exadata storage

可以看到在实际建立过程中Oracle将拒绝在非Exdata存储的表空间上建立该类柱形混合压缩(包括:COMP_FOR_QUERY_HIGH,COMP_FOR_QUERY_LOW,COMP_FOR_ARCHIVE_HIGH,CO MP_FOR_ARCHIVE_LOW)。但DBMS_COMPRESSION在进行评估时可以绕过Oracle对于该类操作的LOCK. 要在没有Exdata存储设备的情况下使用dbms_compression包评测OLTP压缩模式外的柱状混合压缩模式时 (hybrid columnar compression is only supported in tablespaces residing on Exadata storage),首先需要打上patch 8896202:

[oracle@rh2 admin]$ /s01/dbhome_1/OPatch/opatch lsinventory
Invoking OPatch 11.1.0.6.6Oracle Interim Patch Installer version 11.1.0.6.6
Copyright (c) 2009, Oracle Corporation.  All rights reserved.Oracle Home       : /s01/dbhome_1
Central Inventory : /s01/oraInventory
from           : /etc/oraInst.loc
OPatch version    : 11.1.0.6.6
OUI version       : 11.2.0.1.0
OUI location      : /s01/dbhome_1/oui
Log file location : /s01/dbhome_1/cfgtoollogs/opatch/opatch2010-06-02_23-08-33PM.logPatch history file: /s01/dbhome_1/cfgtoollogs/opatch/opatch_history.txtLsinventory Output file location : /s01/dbhome_1/cfgtoollogs/opatch/lsinv/lsinventory2010-06-02_23-08-33PM.txt--------------------------------------------------------------------------------
Installed Top-level Products (1):Oracle Database 11g                                                  11.2.0.1.0
There are 1 products installed in this Oracle Home.Interim patches (1) :Patch  8896202      : applied on Wed Jun 02 21:55:44 CST 2010
Unique Patch ID:  11909460
Created on 29 Oct 2009, 15:21:45 hrs US/Pacific
Bugs fixed:
8896202该patch用以:ENABLE COMPRESSION ADVISOR TO ESTIMATE EXADATA HCC COMPRESSION RATIOS

接着我们还需要运行被修改后的DBMSCOMP包创建SQL,具体操作为:

SQL> @?/rdbms/admin/prvtcmpr.plbPackage created.Grant succeeded.Package body created.No errors.Package body created.No errors.Type body created.No errors.
SQL> @?/rdbms/admin/dbmscomp.sqlPackage created.Synonym created.Grant succeeded.No errors.DBMS_COMPRESSION包在对表压缩进行评估时,默认表最少数据为1000000行,可能在你的测试库中没有这么多数据,我们可以修改这个下限;通过将COMP_RATIO_MINROWS常数修改为1后,就可以分析最小为1行的表了:SQL>create or replace package sys.dbms_compression authid current_user isCOMP_NOCOMPRESS       CONSTANT NUMBER := 1;COMP_FOR_OLTP         CONSTANT NUMBER := 2;COMP_FOR_QUERY_HIGH   CONSTANT NUMBER := 4;COMP_FOR_QUERY_LOW    CONSTANT NUMBER := 8;COMP_FOR_ARCHIVE_HIGH CONSTANT NUMBER := 16;COMP_FOR_ARCHIVE_LOW  CONSTANT NUMBER := 32;COMP_RATIO_MINROWS CONSTANT NUMBER := 10;COMP_RATIO_ALLROWS CONSTANT NUMBER := -1;PROCEDURE get_compression_ratio(scratchtbsname IN varchar2,ownname        IN varchar2,tabname        IN varchar2,partname       IN varchar2,comptype       IN number,blkcnt_cmp     OUT PLS_INTEGER,blkcnt_uncmp   OUT PLS_INTEGER,row_cmp        OUT PLS_INTEGER,row_uncmp      OUT PLS_INTEGER,cmp_ratio      OUT NUMBER,comptype_str   OUT varchar2,subset_numrows IN number DEFAULT COMP_RATIO_MINROWS);function get_compression_type(ownname IN varchar2,tabname IN varchar2,row_id  IN rowid) return number;PROCEDURE incremental_compress(ownname         IN dba_objects.owner%type,tabname         IN dba_objects.object_name%type,partname        IN dba_objects.subobject_name%type,colname         IN varchar2,dump_on         IN number default 0,autocompress_on IN number default 0,where_clause    IN varchar2 default '');end dbms_compression;Package created.SQL> alter package dbms_compression compile body;Package body altered.接下来我们通过建立一个基于TPC-D的测试的Schema,保证各表上有较多的数据,并且数据有一定的拟真度:SQL> select table_name,num_rows,blocks from user_tables ;TABLE_NAME                       NUM_ROWS     BLOCKS
------------------------------ ---------- ----------
DSS_SUPPLIER                        20000        496
DSS_PART                           400000       7552
DSS_REGION                              5          5
DSS_PARTSUPP                      1600000      29349
DSS_LINEITEM                     12000000     221376
DSS_ORDER                         3000000      48601
DSS_CUSTOMER                       300000       6922
DSS_NATION                             25          5现在可以进行压缩评估了,我们针对测试模型Schema编辑以下匿名块并运行SQL> set serveroutput on;
SQL> declarecmp_blk_cnt   binary_integer;uncmp_blk_cnt binary_integer;cmp_rows      binary_integer;uncmp_rows    binary_integer;cmp_ratio     number;cmp_typ       varchar2(100);
BEGINfor i in (SELECT TABLE_NAMEfrom dba_tableswhere compression = 'DISABLED'and owner = 'MACLEAN' and num_rows>1000000) loopfor j in 1 .. 5 loopdbms_compression.get_compression_ratio(scratchtbsname => 'SCRATCH',ownname        => 'MACLEAN',tabname        => i.table_name,partname       => NULL,comptype       => power(2, j),blkcnt_cmp     => cmp_blk_cnt,blkcnt_uncmp   => uncmp_blk_cnt,row_cmp        => cmp_rows,row_uncmp      => uncmp_rows,cmp_ratio      => cmp_ratio,comptype_str   => cmp_typ);dbms_output.put_line(i.table_name || '--' || 'compress_type is ' ||cmp_typ || ' ratio :' ||to_char(cmp_ratio, '99.9') || '%');end loop;end loop;
end;
/
DSS_ORDER--compress_type is "Compress For OLTP" ratio :  1.1%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_ORDER--compress_type is "Compress For Query High" ratio :  2.7%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_ORDER--compress_type is "Compress For Query Low" ratio :  1.7%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_ORDER--compress_type is "Compress For Archive High" ratio :  2.9%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_ORDER--compress_type is "Compress For Archive Low" ratio :  2.7%
DSS_PARTSUPP--compress_type is "Compress For OLTP" ratio :   .9%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_PARTSUPP--compress_type is "Compress For Query High" ratio :  1.8%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_PARTSUPP--compress_type is "Compress For Query Low" ratio :  1.2%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_PARTSUPP--compress_type is "Compress For Archive High" ratio :  1.9%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_PARTSUPP--compress_type is "Compress For Archive Low" ratio :  1.8%
DSS_LINEITEM--compress_type is "Compress For OLTP" ratio :  1.4%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_LINEITEM--compress_type is "Compress For Query High" ratio :  3.5%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_LINEITEM--compress_type is "Compress For Query Low" ratio :  2.3%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_LINEITEM--compress_type is "Compress For Archive High" ratio :  4.3%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
DSS_LINEITEM--compress_type is "Compress For Archive Low" ratio :  3.7%PL/SQL procedure successfully completed.

可以从上述测试看到,"Compress For Archive High"压缩率最高,该类型最适合于数据归档存储,但其算法复杂度高于"Compress For Archive Low",压缩耗时亦随之上升。 总体压缩率都较低,这同TPC-D测试的数据建模有一定关联,我们再使用一组TPC-H的测试数据来模拟压缩:

SQL> conn liu/liu;
Connected.SQL> select num_rows,blocks,table_name from user_tables;NUM_ROWS     BLOCKS TABLE_NAME
---------- ---------- ------------------------------3000000      46817 H_ORDER300000       6040 H_CUSTOMER12000000     221376 H_LINEITEM25          5 H_NATION400000       7552 H_PART5          5 H_REGION1600000      17491 H_PARTSUPP20000        496 H_SUPPLIER8 rows selected.SQL> set serveroutput on;
SQL> declarecmp_blk_cnt   binary_integer;uncmp_blk_cnt binary_integer;cmp_rows      binary_integer;uncmp_rows    binary_integer;cmp_ratio     number;cmp_typ       varchar2(100);
BEGINfor i in (SELECT TABLE_NAMEfrom dba_tableswhere compression = 'DISABLED'and owner = 'LIU' and num_rows>1000000) loopfor j in 1 .. 5 loopdbms_compression.get_compression_ratio(scratchtbsname => 'SCRATCH',ownname        => 'LIU',tabname        => i.table_name,partname       => NULL,comptype       => power(2, j),blkcnt_cmp     => cmp_blk_cnt,blkcnt_uncmp   => uncmp_blk_cnt,row_cmp        => cmp_rows,row_uncmp      => uncmp_rows,cmp_ratio      => cmp_ratio,comptype_str   => cmp_typ);dbms_output.put_line(i.table_name || '--' || 'compress_type is ' ||cmp_typ || ' ratio :' ||to_char(cmp_ratio, '99.9') || '%');end loop;end loop;
end;
/
H_ORDER--compress_type is "Compress For OLTP" ratio :  1.1%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_ORDER--compress_type is "Compress For Query High" ratio :  5.2%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_ORDER--compress_type is "Compress For Query Low" ratio :  2.9%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_ORDER--compress_type is "Compress For Archive High" ratio :  7.2%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_ORDER--compress_type is "Compress For Archive Low" ratio :  5.5%
H_PARTSUPP--compress_type is "Compress For OLTP" ratio :   .9%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_PARTSUPP--compress_type is "Compress For Query High" ratio :  5.1%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_PARTSUPP--compress_type is "Compress For Query Low" ratio :  2.7%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_PARTSUPP--compress_type is "Compress For Archive High" ratio :  7.2%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_PARTSUPP--compress_type is "Compress For Archive Low" ratio :  5.3%
H_LINEITEM--compress_type is "Compress For OLTP" ratio :  1.4%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_LINEITEM--compress_type is "Compress For Query High" ratio :  5.2%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_LINEITEM--compress_type is "Compress For Query Low" ratio :  3.0%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_LINEITEM--compress_type is "Compress For Archive High" ratio :  7.4%
Compression Advisor self-check validation successful. select count(*) on both
Uncompressed and EHCC Compressed format = 1000001 rows
H_LINEITEM--compress_type is "Compress For Archive Low" ratio :  5.6%PL/SQL procedure successfully completed.

可以看到相比TPC-D的测试用数据,TPC-H建立的数据更具可压缩性。 PS: TPC-D represents a broad range of decision support (DS) applications that require complex, long running queries against large complex data structures. Real-world business questions were written against this model, resulting in 17 complex queries. The TPC Benchmark™H (TPC-H) is a decision support benchmark. It consists of a suite of business oriented ad-hoc queries and concurrent data modifications. The queries and the data populating the database have been chosen to have broad industry-wide relevance. This benchmark illustrates decision support systems that examine large volumes of data, execute queries with a high degree of complexity, and give answers to critical business questions. The performance metric reported by TPC-H is called the TPC-H Composite Query-per-Hour Performance Metric (QphH@Size), and reflects multiple aspects of the capability of the system to process queries. These aspects include the selected database size against which the queries are executed, the query processing power when queries are submitted by a single stream, and the query throughput when queries are submitted by multiple concurrent users. The TPC-H Price/Performance metric is expressed as $/QphH@Size.

转载于:https://www.cnblogs.com/macleanoracle/archive/2010/06/02/2967423.html

11g compression 新特性(1)相关推荐

  1. 简单扫一下官文 - 11G Release2 新特性

    简单扫一下官文 - 11G Release2 新特性 简单过一遍官文,详细的以后遇到慢慢研究. 主要的更新在几个方面: 1. OUI的改进 2. Oracle Restart 3. ASM的增强!!! ...

  2. oracle对日期字符串动态分区,oracle 11g分区表新特性---interval分区 的坑

    oracle 11g分区表新特性---interval分区 的坑 oracle 11g的范围分区表中新增的interval分区特性,此种范围分区不需要定义MAXVALUE,Oracle会根据分区定义的 ...

  3. 盘点 Oracle 11g 中新特性带来的10大性能影响

    盘点 Oracle 11g 中新特性带来的10大性能影响 原创 2017-08-02 盖国强 数据和云 Oracle的任何一个新版本,总是会带来大量引人瞩目的新特性,但是往往在这些新特性引入之初,首先 ...

  4. 11g Rman新特性SET NEWNAME

    曾经写过一篇关于如何将RAC的备份异地恢复到单点上的实验过程,连接如下: http://blog.csdn.net/jyjxs/article/details/8727492 其中用到了RMAN的SE ...

  5. 关于oracle 11G 分区表新特性Interval

    oracle 11G新引入的新特性Interval,可以自动根据入库需求创建分区,而不需人工干预. ------------------------月------------------------- ...

  6. ORACLE 11g新特性中文版

    Oracle 11g 新特性 摘自ITPUB的love_zz的帖子 http://www.itpub.net/712880.html Oracle 11g 现在已经开始进行beta测试,预计在2007 ...

  7. 11g R1 R2新特性介绍(针对DBA和开发者)

    首先我要说明:本文主要目的是帮助初级和中级水平的Oracle专业人士了解Oracle系统及更好地优化它.后面的章节里也介绍了不少专家主题,但首要的任务却是协助那些被性能问题折磨得很沮丧的专业人士,他们 ...

  8. ORACLE 11GR2 RAC new features 新特性。

    2009年9月Oracle公司发布了期待已久的Oracle 11g R2,本系列文章将给读者一一揭开新版本中的新特性,并会介绍企业如何利用这些新特性将现有的Oracle 9i,10g,11g R1升级 ...

  9. Oracle 11g 新特性简介

    Oracle 11g于2007年7月11日美国东部时间11时(北京时间11日22时)正式发布,11g是甲骨文公司30年来发布的最重要的数据库版本,根据用户的需求实现了信息生命周期管理(Informat ...

最新文章

  1. pandas将dataframe中的特定数据列的内容转化为列表list数据(convert dataframe column values into a list)
  2. oracle 一致性读数量,ORACLE 一致性读原理记录
  3. python3 遍历列表list 四种方法
  4. freeswitch 把SIP注册信息数据库从SQLITE 改为MYSQL的方法
  5. ASP.NET Core Filter与IOC的羁绊
  6. 新闻发布项目——业务逻辑层(categoryTBService)
  7. java 分层领域模型_Java领域模型 | 学步园
  8. 【ECharts 置图表同序列不同数据点的独立颜色值】
  9. C# 使用AutoResetEvent进行线程同步
  10. php ajax 懒加载demo,lazyload懒加载,怎么支持ajax获得的新内容?
  11. 如约而至!第二期 Flink 极客训练营上线啦
  12. LINUX下载编译libspeex/libspeexdsp
  13. 解决一次模拟post请求的时候,出现中文???的错误
  14. offsetWidth offsetHeight和clientWidth clientHeight的区别
  15. AUTOSAR和OSEK关系及网络管理比较
  16. SDAU信息学院LaTeX模板使用指南
  17. 如何在html中自动生成条形图,Highcharts 柱形图(柱状图及条形图)之通过HTML表格数据创建的柱状图演示...
  18. Hills And Valleys(贪心/枚举)
  19. 动点四边形周长最短_中考数学之四边形周长最小值
  20. js 获取所有被选中复选框的值

热门文章

  1. 栈和队列互相实现,一文弄懂它们的关系
  2. golang中的strings.Trim
  3. ARM汇编:汇编中proc、endp、ret、near、far指令用法
  4. 以太坊(Ethereum ETH)的奖励机制
  5. 【解决方案】MySQL-5.7.9 服务无法启动-“NET HELPMSG 3534”
  6. SQL 中的 AND OR
  7. I/O事件处理模型之Reactor和Proactor 【转】
  8. POJ 3580 SuperMemo
  9. 一个棒棒糖引发的。。。
  10. powertoys中文版