Is the MySQL cardinality number related to the auto-increment counter?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
you can see the next auto_increment value with:
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.