Open justdoit0823 opened 7 years ago
Given your character set (utf8mb3?) VARCHAR is 3 bytes thus VARCHAR(1024) is 3072 bytes. So creating an index on a VARCHAR(1024) just reach the limit.
The multi column index would add an INT as well which is 4 extra bytes. As I understand it that would be a key length of 1024 varchar * 3 bytes / varchar + 1 int + 4 bytes / int = 3076 > 3072.
I have found an interesting aspect about MySQL index. When I create a multi column index, the prefix key field length can't be greater than a specified value.
I create a test table
s_prefix_index
;Then I create a multi column index,
What, I can't create that index as the error is displayed.
And, I found a question in stackoverflow.
However, I can create a single column index with the prefix key field.
Also, there is a document about this condition.
This is an implementation limitation.
But, why ?