What makes a good MySQL index? Part 2: Cardinality « James Cohen
A MySQL indexing walkthrough on cardinality, using a dummy `user` table with composite indexes on (age, sex) and (sex, age). It uses EXPLAIN output to show that high-cardinality columns like age narrow the search far more than a 50/50 column like sex, so the column order in a composite index matters. It also shows the optimizer skipping an index when a query would return most of the table (`age<80` does a full scan, `age>80` uses the index). A later-added section adds that low cardinality can still be useful when the data is skewed: with 9 females among 4,916 rows, `sex="FEMALE"` uses the index while `sex="MALE"` doesn't. The practical lesson is to test with realistic data and queries.