开发者

mysql index cardinality

I have x row count, but all index cardinarlities are much greater than x, how is this possible? If I understand correctly, index cardinality is the number of开发者_如何学C unique rows of that index.


From SHOW INDEX:

Cardinality
An estimate of the number of unique values in the index. This is updated by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on statistics stored as integers, so the value is not necessarily exact even for small tables.


cardinality is not the number of distinct values of an index. rather it is the count of noded in the Btree of the index.

for exampls you created a btree with numbers 1 to 10, you got some 5 nodes and 5 leaves. then your index cardinality can never be more than 5(nodes count)

YES, cardinality can be more than number of rows. This happens when you have index on more than one column. In this case it tries to build a tree with the combination of attributes in the composite index and cadinality will be more than number of rows

Hope U understood... Regards, UDAY.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜