5

I use MySQL and SQLite often and plan on bringing more PostgreSQL into my workflow soon. With that in mind, what are the costs of using NULL in each database? I heard that MySQL adds an extra bit to each NULL column value to mark it as nullable.

1
  • 1
    Some DBMS treat null and empty as the same, as far as strings go (Sybase, MSSQL). For non-string types, a nullable type will always require more storage than a not-nullable type. This is because, as you've stated, you need at least a single bit to indicate whether or not the value is null or not. I suppose some DMBS may be able to compress data in some extent, but in a worst case, a nullable type will always consume more data than a non-nullable type. Commented Nov 30, 2010 at 4:29

1 Answer 1

3

This question was answered separately for PostgreSQL: How much disk-space is needed to store a NULL value using postgresql DB?

and for MySQL: NULL in MySQL (Performance & Storage)

But to recap they both use bitmask fields to mark nulls.

Sign up to request clarification or add additional context in comments.

2 Comments

Do they sill use those bitmask fields even if you don't use nulls?
what about SQLite?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.