Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve perf in account linking (#1394)
## What kind of change does this PR introduce? * Currently, we use an `ilike` which doesn't use the index on `auth.identities.email`. Since the emails in the `verifiedEmails` slice only contains lowercased emails, and the `auth.identities.email` are also guaranteed to be lowercase, there is no need for a case-insensitive search * The partial unique index (`users_email_partial_key`) in auth.users is defined on the condition that `is_sso_user = false`. However, the query uses `is_sso_user is false` which causes it to not use the index ever (along with `ilike`). It would be much faster to do `lower(email) = any (?)` rather than `email ilike any (?)` * Fixes #1390
- Loading branch information