The meaning of the number of presence bits set per column for compression of a single value is provided in the following table.
| Presence Bit Field | Number of Presence Bits | Column Type |
|---|---|---|
| Nullability | 0 | Non-nullable |
| 1 | Nullable | |
| Compressibility | 0 | Not compressed or compressed on nulls only |
| 1 | Compressed on a value |
The total number of presence bits for a given row is the sum of the nullability presence bits and the compressibility presence bits.
The following table expresses the same information in a different way.
| Compressible | Nullable | |||
|---|---|---|---|---|
| Bit Value | Meaning | Bit Value | Meaning | |
| 0 | The column is multivalue compressed. | 0 | The column is null. | |
| 1 | A non-compressed column value is present. | 1 | The column is not null. | |
| An algorithmically compressed column adds an extra bit to indicate whether the column is algorithmically compressed or not, as follows: | ||||
| Compressible | Nullable | |||
| Bit Value | Meaning | |||
| 0 | The column is not algorithmically compressed. | |||
| 1 | The column is algorithmically compressed. | |||
| 1 to 8 bits for each multivalue compressible column (8 bits because 255 compressed values plus null require 28, or 256 bit combinations, to be represented). | 1 bit for each nullable column. | |||
The following table provides a comprehensive mapping of the presence bits and their combinations for the multivalue compression case:
| Presence Bit Value | Column | ||
|---|---|---|---|
| Compress | Null | ||
| no bit | no bit | Not compressible | Not nullable |
| 0 | no bit | Compressed | Not nullable |
| 1 | no bit | Contains uncompressed column values | Not nullable |
| no bit | 0 | Not compressible | Null |
| no bit | 1 | Not compressible | Not null. |
| 0 | 0 | Compressed | Null |
| 1 | 1 | Not compressed | Not null. |
| 1 | 0 | Not compressed | Null |
| 0 | 1 | Not compressed | Null |
Mappings of COMPRESS bit values for multivalued compression generalize from this specific case as illustrated by the following table.
| Presence Bit | Data | |||
|---|---|---|---|---|
| 1 | Not compressed. The corresponding compress bits are all 0. |
|||
| 0 | Compressed.
|
|||
The following table presents a set of examples that clarifies the correspondence between presence bits and data attribute specifications.
| Column Definition | Presence Bits | Character |
|---|---|---|
| col_1 CHAR(1) NOT NULL | None | A |
| col_1 CHAR(1) NOT NULL COMPRESS ('A') | 0 | A |
| 1 | B | |
| col_1 CHAR(1) COMPRESS | 0 | NULL |
| 1 | A | |
| col_1 CHAR(1) COMPRESS ('A') | 00 | NULL |
| 01 | A | |
| 10 | B | |
| 10 | C | |
| col_1 CHAR(1) COMPRESS ('A', 'B', 'C', 'D') | 0000 | NULL |
| 0001 | A | |
| 0010 | B | |
| 0011 | C | |
| 0100 | D | |
| 1000 | E | |
| col_1 CHAR(1) NOT NULL COMPRESS ('A', 'B', 'C', 'D') | 001 | A |
| 010 | B | |
| 011 | C | |
| 100 | D | |
| 000 | E |