edit: added “Low cardinality isn’t always bad” section after Morgan’s comment
As we’ve seen already column size is important for indexes. Cardinality is really important too, it’s the uniqueness of the values included in the index.
Indexes are used by MySQL (and in any RDBMS) to help find rows quickly. We want to make it as easy as possible for MySQL to find the relevant rows, the more precise or specific we are the less the number of rows MySQL has to fetch.
Example Table
For this post I’ve created a table with some dummy data in it. Here’s the SQL I used to create it (in case you want to) which was generated with this hack script.
The table is fairly …
[Read more]