Oracle Database Compression 1 - Basic Compression
Basic Row Compression
This type of compression is intended for bulk load operations.The database does not compress data modified using conventional DML.You must use direct path loads, ALTER TABLE . . . MOVE operations, or online table redefinition to achieve basic compression. When using basic compression, Oracle automatically set the pctfree to zero. For an uncompressed table/partition, alter table xxx compress basic does nothing to the data, user has to issue: alter table xxx move. Subsequently, user needs to rebuild all indexes on that table.
Dictionary-based compression : Table compression works by eliminating column value repetitions within individual blocks. Duplicate values in all the rows and columns in a block are stored once at the beginning of the block, in what is called a symbol table for that block. All occurrences of such values are replaced with a short reference to the symbol table. The compression is higher in blocks that have more repeated values. Because of the compression mechanism, Oracle does not need to decompress the data in buffer cache, it reconstructs the data in PGA, which is a CPU intensive process.
The compression factor is defined as the number of blocks necessary to store the information in an uncompressed form divided by the number of blocks necessary for a compressed storage. The compression factor can be estimated by sampling a small number of representative data blocks of the table to be compressed and comparing the average number of records for each block for the uncompressed and compressed case. Experience shows that approximately 1000 data blocks provides a very accurate estimation of the compression factor. Note that the more blocks you are sampling, the more accurate the result become.
To improve the compression factor you must increase the likelihood of value repetitions within a data block. The achievable compression factor depends on the cardinality of a specific column or column pairs (representing the likelihood of column value repetitions) and on the average row length of those columns. Table compression not only compresses duplicate values of a single column but tries to use multi-column value pairs whenever possible. Without a detailed understanding of the data distribution it is very difficult to predict the most optimal order.
You can declare Basic and Advanced compression at the tablespace, table, partition, or subpartition level.Partitions without a specific declaration inherit the attribute from the table definition or, if nothing is specified on table level, from the tablespace definition.
You can also compress any existing uncompressed table partition later on.
To use table compression on partitioned tables with bitmap indexes, you must do the following before you introduce the compression attribute for the first time:
Mark bitmap indexes unusable.
Set the compression attribute.
Rebuild the indexes.
This does not apply to a partitioned table having B-tree indexes only.To avoid the recreation of any bitmap index structure, Oracle recommends creating every partitioned table with at least one compressed partition whenever you plan to partially or fully compress the partitioned table in the future.
create table tt1 compress basic
as
select * from dba_objects where rownum <= 50000;
create table tt2 nocompress
as
select * from dba_objects where rownum <= 50000;
exec dbms_stats.gather_table_stats(user, 'TT1', cascade=>true);
exec dbms_stats.gather_table_stats(user, 'TT2', cascade=>true);
TABLE_NAME BLOCKS PCT_FREE COMPRESS COMPRESS_FOR
--------------- ---------- ---------- -------- - -----------
TT1 201 0 ENABLED BASIC
TT2 731 10 DISABLED
Another example shows that compression ratio is largely dependent on level of value repetition.
create table tt1 (
tt1_id number(38) primary key,
tt1_name varchar2(100),
tt1_date date
)
partition by range (tt1_date) (
partition p2012 values less than (to_date('2013/01/01','yyyy/mm/dd')) nocompress,
partition p2013 values less than (to_date('2014/01/01','yyyy/mm/dd')) compress basic
)
nologging;
insert /*+ append parallel(2) */ into tt1
select level, to_char('name' || level), to_date('2012/01/01','yyyy/mm/dd')+ mod(level-1,365)
from dual
connect by level<=500000;
commit;
insert /*+ append parallel(2) */ into tt1
select level +500000, to_char('name' || (level+500000)), to_date('2013/01/01','yyyy/mm/dd')+ mod(level-1,365)
from dual
connect by level<=500000;
commit;
exec dbms_stats.gather_table_stats(user,'TT1', cascade=> true);
select partition_name, sum(blocks) from user_tab_partitions
where table_name = 'TT1'
group by partition_name;
PARTITION_NAME SUM(BLOCKS)
------------------------------ -----------
P2013 1844
P2012 2032
This type of compression is intended for bulk load operations.The database does not compress data modified using conventional DML.You must use direct path loads, ALTER TABLE . . . MOVE operations, or online table redefinition to achieve basic compression. When using basic compression, Oracle automatically set the pctfree to zero. For an uncompressed table/partition, alter table xxx compress basic does nothing to the data, user has to issue: alter table xxx move. Subsequently, user needs to rebuild all indexes on that table.
Dictionary-based compression : Table compression works by eliminating column value repetitions within individual blocks. Duplicate values in all the rows and columns in a block are stored once at the beginning of the block, in what is called a symbol table for that block. All occurrences of such values are replaced with a short reference to the symbol table. The compression is higher in blocks that have more repeated values. Because of the compression mechanism, Oracle does not need to decompress the data in buffer cache, it reconstructs the data in PGA, which is a CPU intensive process.
The compression factor is defined as the number of blocks necessary to store the information in an uncompressed form divided by the number of blocks necessary for a compressed storage. The compression factor can be estimated by sampling a small number of representative data blocks of the table to be compressed and comparing the average number of records for each block for the uncompressed and compressed case. Experience shows that approximately 1000 data blocks provides a very accurate estimation of the compression factor. Note that the more blocks you are sampling, the more accurate the result become.
To improve the compression factor you must increase the likelihood of value repetitions within a data block. The achievable compression factor depends on the cardinality of a specific column or column pairs (representing the likelihood of column value repetitions) and on the average row length of those columns. Table compression not only compresses duplicate values of a single column but tries to use multi-column value pairs whenever possible. Without a detailed understanding of the data distribution it is very difficult to predict the most optimal order.
You can declare Basic and Advanced compression at the tablespace, table, partition, or subpartition level.Partitions without a specific declaration inherit the attribute from the table definition or, if nothing is specified on table level, from the tablespace definition.
You can also compress any existing uncompressed table partition later on.
To use table compression on partitioned tables with bitmap indexes, you must do the following before you introduce the compression attribute for the first time:
Mark bitmap indexes unusable.
Set the compression attribute.
Rebuild the indexes.
This does not apply to a partitioned table having B-tree indexes only.To avoid the recreation of any bitmap index structure, Oracle recommends creating every partitioned table with at least one compressed partition whenever you plan to partially or fully compress the partitioned table in the future.
create table tt1 compress basic
as
select * from dba_objects where rownum <= 50000;
create table tt2 nocompress
as
select * from dba_objects where rownum <= 50000;
exec dbms_stats.gather_table_stats(user, 'TT1', cascade=>true);
exec dbms_stats.gather_table_stats(user, 'TT2', cascade=>true);
--------------- ---------- ---------- -------- - -----------
TT1 201 0 ENABLED BASIC
TT2 731 10 DISABLED
create table tt1 (
tt1_id number(38) primary key,
tt1_name varchar2(100),
tt1_date date
)
partition by range (tt1_date) (
partition p2012 values less than (to_date('2013/01/01','yyyy/mm/dd')) nocompress,
partition p2013 values less than (to_date('2014/01/01','yyyy/mm/dd')) compress basic
)
nologging;
insert /*+ append parallel(2) */ into tt1
select level, to_char('name' || level), to_date('2012/01/01','yyyy/mm/dd')+ mod(level-1,365)
from dual
connect by level<=500000;
commit;
insert /*+ append parallel(2) */ into tt1
select level +500000, to_char('name' || (level+500000)), to_date('2013/01/01','yyyy/mm/dd')+ mod(level-1,365)
from dual
connect by level<=500000;
commit;
exec dbms_stats.gather_table_stats(user,'TT1', cascade=> true);
select partition_name, sum(blocks) from user_tab_partitions
where table_name = 'TT1'
group by partition_name;
PARTITION_NAME SUM(BLOCKS)
------------------------------ -----------
P2013 1844
P2012 2032
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-777271/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle Database Compression 3 - Hybrid Columnar CompressionOracleDatabase
- Oracle Database Compression 2 - Advanced/OLTP CompressionOracleDatabase
- Unused Block Compression和Null Block CompressionBloCNull
- Oracle OCP 1Z0-053(Rman Compression Algorithm)OracleGo
- Oracle Index Key Compression索引壓縮OracleIndex索引
- Oracle 11g Advanced Compression(上)Oracle
- Oracle 11g Advanced Compression(下)Oracle
- Oracle OCP 1Z0 053 Q688(RMAN Backup Compression)Oracle
- Oracle OCP 1Z0 053 Q105(Table Compression)Oracle
- Advanced Index CompressionIndex
- Encoder Data compression
- mysql 5.7 Transparent PageIO CompressionMySql
- Oracle Hybrid Columnar Compression(HCC) 混合列壓縮Oracle
- Oracle 表壓縮(Table Compression)技術介紹Oracle
- LZ4 compression algorithm on FPGAGoFPGA
- MySQL5.7 InnoDB Page CompressionMySql
- What’s new in Cassandra 1.0: Compression
- Availability and Compression of Free Space in a Data BlockAIBloC
- MODEL COMPRESSION VIA DISTILLATION AND QUANTIZATION翻譯
- Enhanced Invertible Encoding for Learned Image CompressionEncoding
- Oracle10g備份集壓縮新特性(Backupset Compression)Oracle
- codeforces1450D. Rating Compression
- zt:Different type of RMAN backup compression in 11G
- MySQL 8.0 Reference Manual(讀書筆記78節-- InnoDB Table and Page Compression (1))MySql筆記
- linux CentOS出現Error: xz compression not availableLinuxCentOSErrorAI
- iOS AutoLayout進階(三)Content Compression Resistance PriorityiOS
- 開啟 Gzip後打包 報錯compression-webpack-pluginWebPlugin
- 並查集系列之「路徑壓縮( path compression ) 」並查集路徑壓縮
- [LeetCode] 3163. String Compression IIILeetCode
- iOS autolayout的Content Hugging 和 Content Compression ResistanceiOS
- 10G、11G expdp的compression引數的區別
- [20181127]12c Advanced Index Compression.txtIndex
- 實施vertex compression所遇到的各種問題和解決辦法
- MySQL 8.0 Reference Manual(讀書筆記79節-- InnoDB Table and Page Compression (2))MySql筆記
- Types of Oracle Database Users : Database Administrators (1)OracleDatabase
- oracle全文索引之STOPLIST_1_BASIC_STOPLISTOracle索引
- oracle全文索引之LEXER_1_BASIC_LEXEROracle索引
- oracle10g,11g中的exp,expdp引數compress, compression完全不同的定義Oracle