MySQL Forums
Forum List  »  InnoDB

Re: 3500, 1024, 767 - Maximum Key Length for InnoDB
Posted by: James Day
Date: May 26, 2007 11:30AM

Don't try to create a key on the full length of a URL field! Use a partial prefix key if you need to search or use a hash value like MD5 if you need uniqueness checking and fast lookup by exact URL value. If you use MD5 do remember that you can store the binary version, you don't need to make the field longer by using the character encoding of it.

If you do use the character encoding of MD5, do set the field as some single byte character set, since you don't need the full unicode character range and there's no point in allocating space for three bytes per character. If you're not using the MD5 for uniqueness checks, just to look up records quickly, you'll find that you don't need the full MD5 hash length since it produces a very even distribution of values and a select that occasionally has a duplicated key value is fine.

Don't use CRC for fast hashed lookup of URLs. It produces a non-uniform distribution that's been found to be problematic for URL hashing, notably breaking a router that made the mistake of using it.

You should also read http://bugs.mysql.com/bug.php?id=28138 and exercise caution about using large prefixes in InnoDB with versions from 5.0.26 or 5.1.12 until that bug is fixed.

InnoDB versions before 5.0 don't support partial prefix keys.

James Day, Support Engineer, MySQL AB

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: 3500, 1024, 767 - Maximum Key Length for InnoDB
7937
May 26, 2007 11:30AM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.