mysql optimization - how to explain the problem that mysql primary key is too long and causes secondary indexes to use more space. For example, using uuid as the primary key causes this problem
过去多啦不再A梦
过去多啦不再A梦 2017-05-18 10:53:33
0
1
744

I thought of this after reading Meituan’s article: http://tech.meituan.com/MT_Le... but I don’t quite understand

mysql official original words are:

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

For example, if uuid is used as the primary key, the primary key space becomes larger. Why does it cause the secondary indexes space to also occupy a large space? I don’t understand

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

reply all(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.

This is from the official document, which means that the secondary index will also include the primary, so the larger your primary key, the larger the space occupied by the secondary indexes

Reference: https://dev.mysql.com/doc/ref...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!