0

I need save urls into a mysql table I also need to search rows by their url. In order to increase performance, I want to add UNIQUE index for url column.

CREATE TABLE `fp_feeds_in_records` (
  `id` bigint auto_increment NOT NULL,
  `url` varchar(1000) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  unique unique_url (val)
) ENGINE=InnoDB

But when I run CREATE statement I get error message: Error Code: 1071. Specified key was too long; max key length is 767 bytes. urls I need save are too long so I can't use varchar(255) as other answers suggests. MySQL version is 5.6.35.

How can I solve it?

Cristhian Boujon
  • 4,060
  • 13
  • 51
  • 90

1 Answers1

2

Unfortunately there is no real solution to this. Your only options are to either reduce the size of the column, use a different character set (like UTF-8), or use a different engine (like MYISAM). In this case I switched the character set to UTF-8 which raised the maximum key length to 255 characters.