Search code examples
monetdb

How are null values stored in MonetDB


I have a column of 4 byte integers that contains a lot of Nulls. I would like to know how are null values represented in storage. Do they use up 4 bytes as well or they are handled in a way they don't waste space?


Solution

  • It depends on the data type. For example, in the case on numerical types (int, float, etc) nulls are represented as minimal value of the type. As a result, no extra space is wasted, but one cannot use the smallest possible value for that type.

    For other types, such as boolean columns, some extra space is used, since single bit is not sufficient to represent true, false and null. (It's not a qubit ;) )

    You can find more information here: https://www.monetdb.org/Documentation/Manuals/SQLreference/BuiltinTypes

    The link below provides more developer targeted info (with more details): https://www.monetdb.org/wiki/MonetDB_type_system