Ensuring uniqueness on a varchar greater than 255 in MYSQL/InnoDB
Posted
by
Vijay Boyapati
on Stack Overflow
See other posts from Stack Overflow
or by Vijay Boyapati
Published on 2011-11-23T01:47:36Z
Indexed on
2011/11/23
1:50 UTC
Read the original article
Hit count: 150
I have a table which contains HTML entries for news pages. When I initially designed it I used URL as the primary key. I've learned the error of my ways because left-joining is super slow. So I want to redesign the table with an integer (id) primary key, but still keep the rows unique based on the URL.
The problem is that I've found URLs longer than 255 characters, and MySQL isn't letting my create a key on the URL. I'm using an InnoDB/UTF8 table. From what I understand it's using multiple bytes per character with a limit of 766 bytes for the key (in InnoDB).
I would really love suggestions on an elegant way of keeping the rows unique based on URL, while using an integer primary key.
Thanks!
© Stack Overflow or respective owner