rerat
rerat

Reputation: 375

Mysql error, "Specified key was too long; max key length is 767 bytes" need workaround

I am aware of the index size limit of 767 Bytes when using UTF8, but I need a varchar field to be 512 characters, UTF8 and indexable so that I can update it using INSERT ON DUPLICATE KEY UPDATE. It works fine if the field is 255 characters, but I need to store Windows file paths that are greater than 255 characters, may also contain unicode and foreign characters. Any suggestion for a workaround would be very much appreciated.

Upvotes: 0

Views: 257

Answers (2)

user3089834
user3089834

Reputation: 96

You can store hash of your data on index column and store original data on another column.

SHA1('over 225 character') => 2c42692a0369f4a6060850f1a7997ae7b112d23b

Upvotes: 1

King
King

Reputation: 11

Two workarounds, one is change engine to TokuDB and use clustered index; Another is to use md5 of UTF8 field as key instead of UTF8 filed directly.

Upvotes: 0

Related Questions