DB2 row compression

You can use DB2® row compression to save on storage requirement. You must run the DB2 row compression operation against a directory server instance with the instance owner credentials.

DB2 row compression uses a static dictionary-based compression algorithm to compress data by row. DB2 row compression can replace the repeating patterns that span multiple column values within a row with shorter symbol strings. The row compression on a table is applied by reconstructing the compression dictionary and compressing the information to eliminate fragmented data. Data compression reduces space that is required for the directory server, reduces I/O, and improves performance. When you run the idsdbmaint command to compress rows, the following operations are run:

  • Queries DB2 syscat.tables and fetches all the tables of the directory server instance.
  • Inspects the table and fetches the row compression estimates for each table.
  • Runs the following operations, if the compression estimate is more than 30 percent:
    • Alters the table to enable ROW COMPRESSION.
    • Runs the DB2 reorg command on the table and builds a new compression dictionary.
    • Runs the DB2 runstats command on the table to update all the statistics on the table.
  • Creates a compression dictionary.

To optimize the database, you can run the idsdbmaint command with the row compression parameter. For example:

idsdbmaint -I instance_name -r