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?
Asked
Active
Viewed 1,125 times
5
-
5Why don't you try it out and see for yourself? – Mat Jan 27 '15 at 08:28
1 Answers
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