If you've ever tried to add an index that includes a long varchar column to an InnoDB table in MySQL, you may have seen this error:
ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
The character limit depends on the character set you use. For example if you use
latin1 then the largest column you can index is
varchar(767), but if you use
utf8 then the limit is
varchar(255). There is also a separate 3072 byte limit per index. The 767 byte limit is per column, so you can include multiple columns (each 767 bytes or smaller) up to 3072 total bytes per index, but no column longer than 767 bytes. (MyISAM is a little different. It has a 1000 byte index length limit, but no separate column length limit within that).
One workaround for these limits is to[Read more...]