Oracle 11g extends the use of compressed
tables to be used for all DML operations. Previous
releases of Oracle only supported compression for
direct-path inserts. Using compression saves disk
space, reduces memory use in the buffer cache and increases
the speed of read operations. Compressed tables
typically consume two to three times less disk space than
uncompressed copies of the same data. The concept of data
compression fits well with new technology trends such as
larger and faster memory and the use of solid-state disks.
While data compression has many benefits, note that it does
incur a CPU overhead when writing data.
Oracle 11g uses a table compression
algorithm that minimizes the performance overhead of using
compression for OLTP tables. The algorithm works by
compressing a block in batch mode instead of each time a
write operation takes place. A newly initialized block
becomes compressed only after reaching an internally
controlled threshold, at which time all data in the block is
compressed. For an OLTP table, this guarantees a high
level of compression and limits the performance overhead to
only transactions that trigger the block compression.
The frequency of triggering block compression will be
affected by the block size and row length. In most
cases, the overwhelming majority of transactions will have
the same performance when writing to compressed blocks as
uncompressed blocks. Once the blocks have been compressed,
Oracle can read the compressed blocks directly without
requiring the block to first be uncompressed.
This new enhancement for table
compression allows data compression to be utilized in OLTP
environments. By default, enabling compression by
using ?compress? in a table's DDL will be the same as
specifying compress for
direct_load operations. The syntax to enable
compression for all DML operations is ?compress for all
operations? in the compression portion of the table's DDL:
create
table
table_name ( ... )
compress
for all operations;
To enable compression for all DML on an
uncompressed table, the alter table syntax is:
alter table
table_name
compress
for all operations;
To disable compression for all DML
operations and only use it for direct-path inserts, the
syntax is:
alter table
table_name
compress
for direct_load operations;
To completely disable compression from a
table, the syntax is:
alter table
table_name
nocompress;
For
partitioned tables, compression can be controlled at the
partition level. This allows the same table to have
partitions that are compressed differently. Defining
compression at the partition level overrides the compression
settings at the table level, allowing for a finer level of
control for compressing large tables based on specific
business requirements.