Does using optional fields have a positive impact on database performance?
Hi, I have a table where I can make some fields optional, and it seems that having them unset rather than containing thousands of false values might be beneficial. Is this a good practice, what do you think?
2 Replies
optional fields don't take any space in the document, while a false value would take up space similar to what it would occupy in json format. A document's size impacts performance (although differences <1kb are usually negligible) and contributes to bandwidth and storage costs.
Personally I would use whatever data format best fits my app; a few false values in each document should not make a difference. but using optional fields instead of false/null values, especially if there are many per document, could be beneficial
Thank you!