MySQL Explain 中的 key_len

MySQL About 491 words

含义

  • 字段允许为null,则key_len需额外加1
  • 字段不允许为nullkey_len不需要加字节(可变长度类型额外加2)

详细信息

列类型 KEY_LEN 备注
id int key_len = 4+1 int为4bytes,允许为NULL,加1byte
id bigint not null key_len=8 bigint为8bytes,不为null,不加1
user char(30) utf8 key_len=30*3+1 utf8每个字符为3bytes,允许为NULL,加1byte
user varchar(30) not null utf8 key_len=30*3+2 utf8每个字符为3bytes,变长数据类型,加2bytes
user varchar(30) utf8 key_len=30*3+2+1 utf8每个字符为3bytes,允许为NULL,加1byte,变长数据类型,加2bytes
detail text(10) utf8 key_len=10*3+2+1 TEXT截取部分,被视为动态列类型。
Views: 1,878 · Posted: 2019-04-04

————        END        ————

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓


Today On History
Browsing Refresh