Compressing your data
You can reduce the space required for a table by using data compression. Compressing the data in a table space can significantly reduce the amount of disk space that is needed to store data and can help improve buffer pool performance.
Before you begin
FL 504The TS_COMPRESSION_TYPE subsystem parameter specifies the default compression algorithm that is used to compress Db2 data at the subsystem level.
FL 509 The COMPRESS option of the ALTER TABLESPACE, CREATE TABLE, and CREATE TABLESPACE statements can define the compression algorithm that is used to compress Db2 data at the table space or partition level.
You can use the DSN1COMP utility to determine how well compression of your data will work.
For fixed-length compression, the CPU cost of both compression and decompression increases with smaller compression ratios. Therefore, it is best to avoid the use of compression if the compression ratio, or the percentage of saved space due to compression, is less than 10 - 20 percent. The additional CPU cost for compression and decompression makes it not worthwhile.
In general, Huffman compression provides better compression ratios, but has a higher CPU cost than fixed-length for decompression.Data in a table space that is defined in the work file database (the table space for declared temporary tables) cannot be compressed.
Data in a table space that is defined in the work file database (the table space for declared temporary tables) cannot be compressed.
About this task
When you compress data, bit strings that occur frequently are replaced by shorter strings. Information about the mapping of bit strings to their replacements is stored in a compression dictionary. Computer processing is required to compress data before it is stored and to decompress the data that is retrieved from a page in the buffer pool. In many cases, using the COMPRESS clause can significantly reduce the amount of disk space needed to store data, but the compression ratio that you achieve depends on the characteristics of your data.
- Higher buffer pool hit ratios
- Fewer I/Os
- Fewer getpage operations
To compress data:
- To compress data when Db2 is using fixed-length compression, see Using fixed-length compression to compress your data.
- To compress data when Db2 is using Huffman compression, see Using Huffman compression to compress your data