Does MySQL index NULL values?

前端 未结 6 1245
再見小時候
再見小時候 2020-12-04 21:17

I have a MySQL table where an indexed INT column is going to be 0 for 90% of the rows. If I change those rows to use NULL instead of 0, will they b

6条回答
  •  猫巷女王i
    2020-12-04 21:37

    Allowing a column to be null will add a byte to the storage requirements of the column. This will lead to an increased index size which is probably not good. That said if a lot of your queries are changed to use "IS NULL" or "NOT NULL" they might be overall faster than doing value comparisons.

    My gut would tell me not null, but there's one answer: test!

提交回复
热议问题