tags:

views:

60

answers:

4

What is cardinality in MySQL? PLease explain 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?

+2  A: 

http://en.wikipedia.org/wiki/Cardinality_(SQL_statements)

Kami
Linking wiki != explaining
kemp
Absolutely Correct
OM The Eternity
+1  A: 

It is an estimate of the number of unique values in the index.

For a table with a single primary key column, the cardinality should normally be equal to the number of rows in the table.

More information.

Rhapsody
+3  A: 

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.

disown
+1  A: 

It's basically associated with the degree of uniqueness of a column's values as per the Wikipedia article linked to by Kami.

Why it is important to consider is that it affects indexing strategy. There will be little point indexing a low cardinality column with only 2 possible values as the index will not be selective enough to be used.

Martin Smith