MySQL索引的大小限制是什么意思? [英] What does size limit on MySQL index mean?

查看:182
本文介绍了MySQL索引的大小限制是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个像这样创建的表:

I have a table created like so:

CREATE TABLE `my_table` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`info` varchar(50) DEFAULT NULL,
`some_more_info` smallint(5) unsigned NOT NULL
PRIMARY KEY (`id`),
KEY `my_index` (`some_more_info`,`info`(24)),
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8

我的问题是关于名为 my_index 的第二个密钥。 (24)大小限制是什么意思?列的实际大小为50,但索引仅为24个字符。

My question is about the second key called my_index. What does the "(24)" size limit mean? The actual size of the column is 50, but the index is only 24 characters.

这是否意味着MySQL仅索引列的前24个字符 info

Does this mean that MySQL indexes only the first 24 characters of the column info?

推荐答案

简而言之,是的,构建BTree索引时会考虑前24个字符。索引限制被分配给文本类型,例如varchar和text,因为它们不会影响数字精度。

In short, yes, the first 24 characters are taken into consideration to build the BTree index. Indexing limits are assigned to text types such as varchar and text, as they don't affect numeric precision.

这篇关于MySQL索引的大小限制是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆