Two key concepts in DB2 that you always need to remember. The number one is compression and the other one is VARCHAR.
The below post is a summary of difference between these two concepts.
Even though these are two entirely different “things,” they are each probably done for similar reasons – to save disk storage.
Comparison: Compression Vs VARCHAR
- With variable columns you always add overhead: there is a two-byte prefix for every VARCHAR column to store the length of the VARCHAR.
- If instead you use CHAR and turn on compression you no longer need the extra two bytes per row per variable column.
- All in all, that means that comrpession can return better disk storage savings than variable columns, and all without the programmatic overhead of having to calculate and store the two-byte prefix for each previously variable column.