Cardinality in this context is the relation of uniqueness of the data according to the index key. It is usually better to have high cardinality, that is, the closer the key produces unique values, the better. Low cardinality usually impairs speed and may even make it impossible to use the index. Examples:
- A sex column will probably have cardinality 2 (almost as low as possible it is 1, which would indicate that the field is not suited for something useful)
- An ID column will have the same number of rows in the table (the highest possible)
- Key indexes that generate the same combination of columns have the same cardinality
The cardinality will only change - by any of the 3 possible SQL operations - if the column data involved in the index key changes.
This is a statistic that can be used to decide whether to use an index or not. It’s not that important. So it doesn’t need to be up to date all the time, so it only usually has an update when using a ANALYZE TABLE
. Phpmyadmin probably does this without you knowing it. If you want to force the update of statistics, do it in your code. But think about it, if it’s not something that’s always done, because you should?
Is in the documentation.