there is a index key limit
- single key length : 767 bytes
- total key length : 3072 bytes
for single key limit:
- innodb
- innodb_large_prefix = on
- innodb_file_format = Barracuda
- Table Row-Format: ROW_FORMAT=DYNAMIC
the total key length limit is hard check.
for case
SomeCol varchar(1000)
if innoDB+utf8, it works use someCol to create index when large-prefix on (3*1000=3000)
if innoDB+utf8mb4, it not work as large than 3072(4*1000 = 4000)
other solutions
for index base on large colums, mysql offer prefix index, as only use a part of the colum value as index.
- prefix length should easy to compare
- can not be used in order by/group by
mysql-error-1071-specified-key-was-too-long-max-key-length-is-767-bytes
本文由 Ivan Dong 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jun 13, 2023 at 09:28 am