tags:

views:

68

answers:

1

Hello guys,

Recently, I've been thinking if it's worth to have 1 table with perhaps a lot of NULL columns or if it's better to have more tables with no NULLs. I've heard that NULL isn't stored on InnoDB, so I was wondering if there is any downside or problem with having a bunch of rows with a lot of NULLs. I have always heard that common NULLs are bad, but I have never really learned why. By the way, those will be NULLs on foreign keys, if that matters at all.

On a second doubt, is there any performance issue when I'm using INNER JOIN on columns that have a lot of NULL? Like, if I have 4 foreign keys, and I'm going to do 4 INNER JOINs, but most likely only 1 of them is not NULL, is this going to affect perfomance? Thanks

+1  A: 

See:

NULLs are indexed.

In InnoDB, you can reduce the storage requirements for your data row by using NULL.

Bill Karwin
Hi Bill, thank you for your answer. I'd like to know more the performance impact of doing INNER JOIN on columns that have a lot of NULLs. Is this bad?
Clash
I can't cite any quantitative measurements, but I believe any performance difference would be negligible. You'd definitely be better off focusing your attention on performance improvements that give better bang for the buck, like using `EXPLAIN`, and caching intelligently.
Bill Karwin