Possible Duplicate:
Space used by nulls in database

In addition efficient when it comes to space for storage?

  • A nullable int column filled with nulls.
  • An int column filled with zeroes.

I understand a nullable column occupies 1 extra little bit of information to keep its null condition, but do null values save the database from allocating 32 bits to have an int that's null?

(null semantics and also the concept of null aren't essential for this)

For fixed width fields like nullable int the space for storage needed is definitely exactly the same no matter if the value is null or otherwise.

For variable width nullable fields the worthiness ’NULL‘ takes zero bytes of space for storage (disregarding the part to keep if the value is null or otherwise).

If you work with SQL Server 2008, and have a much a substantial quantity of NULL values in posts, I recommend you investigate Sparse Columns. They're enhanced for storing NULL values.

SQL Server 2008 introduced Sparse columns for posts which are mainly NULL.

A SPARSE column for any row, that is NULL uses items of storage. However, you pay a 4 byte penalty if there's something.

isn't null. Without having something for that area, don't stick a zero inside! I can not let you know the number of occasions I have run into bugs which are basically unfixable because we've not a way of knowing if the zeros inside a production database were real zeros or fake nulls. Embrace nulls - yes, they might require a little more coding, but embrace them anyway.