Question about mysql indexes on low to medium cardinality columns
Posted
by Kevin J
on Stack Overflow
See other posts from Stack Overflow
or by Kevin J
Published on 2010-03-16T06:08:01Z
Indexed on
2010/03/16
6:16 UTC
Read the original article
Hit count: 261
I have a general question about the way that database indexing works, particularly in mysql. Let's say I have a table with a million rows with a column "ClientID" that is distributed relatively equally among 30 values. Thus, this column is very low cardinality (30) relative to the primary key (1 million).
Now, I understand that you shouldn't create indexes on low cardinality fields. However, in this case, queries are only ever done with one of the 30 clientIDs. Thus, wouldn't creating an index on ClientID be helpful, as the search space is automatically reduced to 1/30th what it normally would be? Or is my understanding of how the index works flawed?
Thanks
© Stack Overflow or respective owner