mysqlindexing

What is cardinality in MySQL?


What is cardinality in MySQL? Please explain in simple, non-technical language.

If a index detail of any table displays the cardinality of a field say group_id as 11, then what does that mean?


Solution

  • Max cardinality: All values are unique

    Min cardinality: All values are the same

    Some columns are called high-cardinality columns because they have constraints in place (like unique) prohibiting you from putting the same value in every row.

    Cardinality is a property which affects the ability to cluster, sort and search data. It is therefore an important measurement for the query planners in DBs, it is a heuristic which they can use to choose the best plans.