views:

320

answers:

1

Is the MySQL cardinality number related to the auto-increment counter?

+2  A: 

the cardinality of a column is the number of distinct values stored in that column. indexes are more selective when used on columns with high cardinality.

for a unique non-null column (such as an auto_increment), the cardinality is equal to the number of rows essentially. the max(id) may be much higher tho, since there can be holes in the sequence left after deletions and such....

you can check the cardinality of a column by looking at its index:

show index from t;

you can see the next auto_increment value with:

show table status like 't';

the values might be the same (or one higher), but it's not necessarily always the case, since the numbering doesn't stay sequential when you delete or insert with an explicit value for the auto_increment field.

jspcal
where t = name of table ... ty for the query references :-)
yos