When a user registers, email must be unique, and the registration check must take 1 second at most.
How does Facebook / Google manage to perform a select on table with several billion rows, retrieving instant response.
Is it as simple as:
select email from users where email = "[email protected]" limit 1
Does having an index on email
field and running this query on a super fast server do the trick?
Or is there more to it?
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
ALTER TABLE `users` ADD INDEX `users_idx_email_zzz` (`email`,`zzz`);
SELECT
users.email
FROM
users
WHERE
users.email = users."[email protected]" LIMIT 1