mysql优化 - 如何解释mysql主键太长导致secondary indexes使用更多空间的问题, 如用uuid当主键导致这个问题
过去多啦不再A梦
过去多啦不再A梦 2017-05-18 10:53:33
[MySQL讨论组]

我是看了美团的文章 : 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空间占用也大呢, 搞不明白

过去多啦不再A梦
过去多啦不再A梦

全部回复(1)
習慣沉默

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...

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号