MySQL issue with UTF8 and large indexes

Today I ran into a very annoying MySQL issue. Basically, I can’t create a multi-part unique index for one of my tables because I get the following error.


Error executing SQL commands to update table.
MySQL Error Nr. 1071
Specified key was too long; max key length is 1024 bytes

At first, I was very confused because the multi-part index was only two VARCHAR(255) fields, which by my guess should only be 510 bytes. When googling, I found the bug report and the reason this is happening. UTF8 is reserving 3 bytes for every character, not 1 byte for every character like a typical ASCII field would.

Unfortunately, MySQL doesn’t view this as a high priority so I have to lower the length of my columns. This limitation is pretty annoying to begin with. If a user wants to hurt their performance by having very large key values, why not let them?

Post to Twitter Post to Delicious Post to Digg Post to Facebook Post to Reddit

Leave a Reply