MySQL Cardinality vs Auto-Increment Counter
Is the MySQL cardinality numb开发者_开发问答er related to the auto-increment counter?
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.
精彩评论