Does UNIQ constraint mean also an index on that field(s)?

Posted by Gremo on Stack Overflow See other posts from Stack Overflow or by Gremo
Published on 2012-03-19T02:00:36Z Indexed on 2012/03/19 2:03 UTC
Read the original article Hit count: 155

Filed under:
|

As title, should i defined a separate index on email column (for searching purposes) or the index is "automatically" added along with UNIQ_EMAIL_USER constraint?

CREATE TABLE IF NOT EXISTS `customer` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `first` varchar(255) NOT NULL,
  `last` varchar(255) NOT NULL,
  `slug` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `UNIQ_SLUG` (`slug`),
  UNIQUE KEY `UNIQ_EMAIL_USER` (`email`,`user_id`),
  KEY `IDX_USER` (`user_id`)
) ENGINE=InnoDB;

© Stack Overflow or respective owner

Related posts about mysql

Related posts about sql