HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Will my sqlite database occupy less space if I insert nulls instead of zeros

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
zerosspaceinsertsqliteoccupydatabaseinsteadwilllessnulls

Problem

I have a table where most of the values inserted in one of the columns are 0. Should the database be smaller if I insert nulls instead of zeros?

Solution

In the SQLite record format, both NULL and the integer 0 need only a type code and no storage for the actual value itself.

In any case, you should use whatever value works best with your queries, and optimize only when needed.

Context

StackExchange Database Administrators Q#90271, answer score: 5

Revisions (0)

No revisions yet.