Does MySQL index NULL values?

前端 未结 6 1240
再見小時候
再見小時候 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条回答
  •  庸人自扰
    2020-12-04 21:28

    No, it will continue to include them, but don't make too many assumptions about what the consequences are in either case. A lot depends on the range of other values (google for "cardinality").

    MSSQL has a new index type called a "filtered index" for this type of situation (i.e. includes records in the index based on a filter). dBASE-type systems used to have a similar capability, and it was pretty handy.

提交回复
热议问题