5

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?

bat_ventzi
  • 173
  • 5

1 Answers1

5

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.

CL.
  • 5,213
  • 1
  • 20
  • 23
  • +1 for storing what's logically best for your queries. If you really have many columns that are often null or zero, maybe you need a different data model? – Colin 't Hart Jan 28 '15 at 10:05