I know that adding
LIMIT 1 when searching for only one record makes a lot of difference when it comes to performance. But does it still have any effect when we search a column with a unique constraint?
Let us say I store email records with a
id (int) primary key column and the
LIMIT 1 in my queries to speed up the returning of a result set? Or does the MySQL engine understand that as soon as one record is found the result can be returned since the field is marked as unique and is
LIMIT 1 obsolete?
MySQL table definition:
CREATE TABLE Email ( `id` int NOT NULL, `email` varchar(255) NOT NULL, PRIMARY KEY (`id`), UNIQUE (`email`) )
Does it in this case make a difference whether I do:
SELECT * WHERE `email`="firstname.lastname@example.org";
SELECT * WHERE `email`="email@example.com" LIMIT 1;