如何解释mysql主键太长导致secondary indexes使用更多空间的问题, 如用uuid当主键导致这个问题

发布于 2022-09-04 22:51:11 字数 355 浏览 12 评论 0

我是看了美团的文章 : http://tech.meituan.com/MT_Le... 想到的, 不太明白

mysql官方原话是:

If the primary key is long, the secondary indexes use more space, so it is advantageous to have a short primary key

比如 uuid 当主键, 主键空间就变大了, 为啥会导致secondary indexes空间占用也大呢, 搞不明白

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

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

发布评论

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

评论(1

行至春深 2022-09-11 22:51:11

All indexes other than the clustered index are known as secondary indexes. In InnoDB, each record in a secondary index contains the primary key columns for the row, as well as the columns specified for the secondary index. InnoDB uses this primary key value to search for the row in the clustered index.

这个是官方文档中的,意思是secondary index也会包含primary,所以你主键越大,secondary indexes空间占用也越大

参考:https://dev.mysql.com/doc/ref...

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