-- 0035_users_mail_index.sql -- Index on users.mail. -- -- The authentication paths all look an account up by mail: password reset, -- e-mail verification, duplicate-address detection and the verify/resend -- cooldown all resolve a single user from a submitted address. Without an index -- each of those is a full table scan of `users`, which grows with every -- registration. -- -- Deliberately NOT unique. Legacy rows predate the duplicate-address handling -- and can legitimately contain the same address more than once, so a unique -- index would fail to apply on an existing database. The lookup is made -- deterministic by ordering on `id` (see requestReset / the verify page), which -- is stable without the index and correct with it. -- -- The column is VARCHAR(500), which exceeds the 767-byte InnoDB prefix limit on -- older row formats, hence an explicit 191-character prefix: enough to make the -- lookup selective and still indexable everywhere. CREATE INDEX IF NOT EXISTS `users_mail_index` ON `users` (`mail`(191));