|
网上的解释炒来炒去,都没有正式的,特地从beta文档萜一段
Table Compression
The database can use table compression to eliminate duplicate values in a data block. For tables with highly redundant data, compression saves disk space, reduces memory use in the database buffer cache, and in some cases speeds query execution. Table compression is transparent to database applications.
Basic and OLTP Table Compression
Oracle Database supports the following types of table compression:
•Basic table compression
This type of compression is intended for data warehouse applications and offers a high compression ratio and low CPU overhead.
•OLTP table compression
This type of compression is intended for OLTP applications and offers a high compression ratio and low CPU overhead.
The database stores compressed rows in row-major format. All columns of one row are stored together, followed by all columns of the next row, and so on (see Figure 12-6). Duplicate values are replaced with a short reference to a symbol table stored at the beginning of the block. Thus, information needed to re-create the uncompressed data is stored in the data block itself.
Compressed data blocks look much like normal data blocks. Most database features and functions that work on regular data blocks also work on compressed blocks.
Hybrid Columnar Compression
In hybrid columnar compression, the database stores the same column for a group of rows together. This type of compression can provide a very high degree of size reduction. Database operations work transparently against these compressed objects so no application changes are required.
You can specify the following types of hybrid columnar compression depending on your requirements:
•Warehouse compression
This type of compression is intended for data warehouses. You can specify COMPRESS FOR QUERY at a low or high (default) level. Typically, a higher level has a higher compression ratio and cost during load and access time.
•Online archival compression
This type of compression is suitable for long-term archived data or OLTP partitions that rarely or never change. You can specify COMPRESS FOR ARCHIVE at a low (default) or high level.
Hybrid column compression does not store data in the row-major format used by basic and OLTP table compression. The database stores a row set in a compression unit, which is an internal storage format, and manages the compressed data transparently. For example, the database could divide a million-row sales table into row subsets and within each subset store product IDs together, customer IDs together, and so on.
Compression Declaration
You can declare compression at the tablespace, table, partition, or subpartition level. If specified at the tablespace level, then all tables created in that tablespace are compressed by default.
The following applies online archival compression to the sales table:
ALTER TABLE sales
ORGANIZATION HEAP
COMPRESS FOR ARCHIVE;
The following example of a CREATE TABLE statement specifies warehouse compression for one partition and online archival compression for the other partition:
CREATE TABLE sales (
prod_id NUMBER NOT NULL,
cust_id NUMBER NOT NULL, ... )
PCTFREE 5 NOLOGGING NOCOMPRESS
PARTITION BY RANGE (time_id)
( partition sales_1995 VALUES LESS THAN(TO_DATE(...)) COMPRESS FOR ARCHIVE,
partition sales_1996 VALUES LESS THAN(TO_DATE(...)) COMPRESS FOR QUERY, ... );
See Also:
•"Data Block Compression" to learn about the format of compressed data blocks
•Oracle Database Administrator's Guide and Oracle Database Performance Tuning Guide to learn about table compression
•Oracle Database PL/SQL Packages and Types Reference to learn about the DBMS_COMPRESSION package for columnar compression |
|