This is a fairly straight forward question but I'm having a problem finding a clear answer googling around. On MySQL 5.1.53, using InnoDB, and a varchar(1024) field (I'm indexing Exchange 2010 Event IDs). I'm wondering what the maximum key length is when I index this field. I'm wondering if I should shorten the field and use something like an sha512 hash if the key length isn't long enough.
            Asked
            
        
        
            Active
            
        
            Viewed 4,101 times
        
    1
            
            
        - 
                    The answer to this question was already given [here](http://stackoverflow.com/questions/3489041/mysqlerror-specified-key-was-too-long-max-key-length-is-1000-bytes/3489331#3489331) and [there](http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes/1814594#1814594). – dma_k Nov 10 '11 at 10:24
1 Answers
7
            The InnoDB internal maximum key length is 3500 bytes, but MySQL itself restricts this to 3072 bytes. This limit applies to the length of the combined index key in a multi-column index.
And, as noted:
An index key for a single-column index can be up to 767 bytes. The same length limit applies to any index key prefix. See Section 12.1.13, “CREATE INDEX Syntax”.
http://dev.mysql.com/doc/refman/5.1/en/innodb-restrictions.html
 
    
    
        Joe
        
- 41,484
- 20
- 104
- 125
