Is storage space wasted when storing null data?

I am using sqlite database.
When adding records, disk space is obviously used for non-null data. But what about data records containing null values? Why am I asking that I will have a large number of columns (50+) and millions of records that will contain null data while Im wondering if its the most efficient way to design my database.

+3


source to share


1 answer


In SQLite record format , exactly one byte should indicate what the value is NULL

.

If you normalize your database to have one record per value not NULL

, you keep those NULL

bytes, but you have additional overhead for the values NULL

. Minimum recording on the SQLite : :



  • cell pointer with two bytes,
  • at least one byte length of the payload,
  • multiple bytes for rowid

    and
  • for your case, a few bytes for a foreign key that points to the original record.

In addition, storing values ​​in a non- NULL

separate table may require an index for efficient searches.

+3


source







All Articles