MySQL 基数与自动递增计数器

发布于 2024-08-17 05:36:28 字数 24 浏览 4 评论 0原文

MySQL基数与自增计数器有关吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮光沉寂 2024-08-24 05:36:28

列的基数是该列中存储的不同值的数量。当用于具有高基数的列时,索引更具选择性。

对于唯一的非空列(例如 auto_increment),基数本质上等于行数。 max(id) 可能要高得多,因为删除后留下的序列中可能存在漏洞等等......

您可以通过查看列的索引来检查列的基数:

show index from t;

您可以使用以下命令查看下一个 auto_increment 值:

show table status like 't';

值可能相同(或更高),但情况不一定总是如此,因为当您删除或插入 auto_increment 字段的显式值时,编号不会保持顺序。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文