The selected VARCHAR and Compression differences in DB2

Even though these are two entirely different “things,” they are each probably done for similar reasons – to save disk storage.

  • 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.

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.