O
O
Optimus2016-07-27 10:12:57
MySQL
Optimus, 2016-07-27 10:12:57

Empty field storage and fetch?

In the documentation they write that, if possible, it is necessary to make the field NOT NULL. this saves one byte per line. Question: which version of an empty field (no value) takes up less space in the database and is searched faster?
NULL, 0, '' (empty string) or something else?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2016-07-27
@Nipheris

0 is not an option for an empty field if you are storing the amount of something. Also with an empty string - this is not always the equivalent of NULL. Null is not even empty at all, but an "unknown" value - it is important to understand the difference.
As for me, there is no more perverted way to set yourself a rake, how to save space in the database using / not using NULL. This should be entirely domain specific. I don't think any DBMS is so terrible that it will waste twice as much space on nullable values.

M
Maxim Fedorov, 2016-07-27
@qonand

As for null in MySQL, if possible, you should get rid of it (only without fanaticism). You need to understand that for each data type you need to use its own default value, if the type is a string, then "" is better, if a number is then 0, etc. Well, accordingly, the default value will take up as much space as the column type itself takes. You can read more about the sizes of data types here.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question