MySQL: low cardinality/selectivity columns = how to index?

前端 未结 7 1264
既然无缘
既然无缘 2020-12-04 15:31

I need to add indexes to my table (columns) and stumbled across this post:

How many database indexes is too many?

Quote: “Having said that, you can clearly

7条回答
  •  遥遥无期
    2020-12-04 16:14

    I have a similar column in my MySQL database. Approximately 4 million rows, with the distribution of 90% 1 and 10% 0.

    I've just discovered today that my queries (where column = 1) actually run significantly faster WITHOUT the index.

    Foolishly I deleted the index. I say foolishly, because I now suspect the queries (where column = 0) may have still benefited from it. So, instead I should explicitly tell MySQL to ignore the index when I'm searching for 1, and to use it when I'm searching for 0. Maybe.

提交回复
热议问题