-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: improve perf in account linking #1394
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kangmingtay
force-pushed
the
km/fix-improve-perf
branch
from
February 2, 2024 03:46
dd58ab3
to
5f90ed3
Compare
kangmingtay
force-pushed
the
km/fix-improve-perf
branch
from
February 2, 2024 03:48
5f90ed3
to
ca39ae7
Compare
2 tasks
tasgon
reviewed
Feb 2, 2024
J0
previously approved these changes
Feb 2, 2024
J0
dismissed
their stale review
February 2, 2024 09:31
Sounds like we might need to use a partial index, remove lower, or something else
J0
approved these changes
Feb 5, 2024
decided to remove the case-insensitive search here since gotrue will lowercase all emails before inserting / updating a user record in the database if we want to be really safe, we can add an index to enforce uniqueness on lower(email) but that will be for a FLUP PR |
J0
pushed a commit
that referenced
this pull request
Feb 12, 2024
🤖 I have created a release *beep* *boop* --- ## [2.139.2](v2.139.1...v2.139.2) (2024-02-08) ### Bug Fixes * improve perf in account linking ([#1394](#1394)) ([8eedb95](8eedb95)) * OIDC provider validation log message ([#1380](#1380)) ([27e6b1f](27e6b1f)) * only create or update the email / phone identity after it's been verified ([#1403](#1403)) ([2d20729](2d20729)) * only create or update the email / phone identity after it's been verified (again) ([#1409](#1409)) ([bc6a5b8](bc6a5b8)) * unmarshal is_private_email correctly ([#1402](#1402)) ([47df151](47df151)) * use `pattern` for semver docker image tags ([#1411](#1411)) ([14a3aeb](14a3aeb)) ### Reverts * "fix: only create or update the email / phone identity after i… ([#1407](#1407)) ([ff86849](ff86849)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
uxodb
pushed a commit
to uxodb/auth
that referenced
this pull request
Nov 13, 2024
## 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 supabase#1390
uxodb
pushed a commit
to uxodb/auth
that referenced
this pull request
Nov 13, 2024
🤖 I have created a release *beep* *boop* --- ## [2.139.2](supabase/auth@v2.139.1...v2.139.2) (2024-02-08) ### Bug Fixes * improve perf in account linking ([supabase#1394](supabase#1394)) ([8eedb95](supabase@8eedb95)) * OIDC provider validation log message ([supabase#1380](supabase#1380)) ([27e6b1f](supabase@27e6b1f)) * only create or update the email / phone identity after it's been verified ([supabase#1403](supabase#1403)) ([2d20729](supabase@2d20729)) * only create or update the email / phone identity after it's been verified (again) ([supabase#1409](supabase#1409)) ([bc6a5b8](supabase@bc6a5b8)) * unmarshal is_private_email correctly ([supabase#1402](supabase#1402)) ([47df151](supabase@47df151)) * use `pattern` for semver docker image tags ([supabase#1411](supabase#1411)) ([14a3aeb](supabase@14a3aeb)) ### Reverts * "fix: only create or update the email / phone identity after i… ([supabase#1407](supabase#1407)) ([ff86849](supabase@ff86849)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 13, 2024
## 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 supabase#1390
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 13, 2024
🤖 I have created a release *beep* *boop* --- ## [2.139.2](supabase/auth@v2.139.1...v2.139.2) (2024-02-08) ### Bug Fixes * improve perf in account linking ([supabase#1394](supabase#1394)) ([8eedb95](supabase@8eedb95)) * OIDC provider validation log message ([supabase#1380](supabase#1380)) ([27e6b1f](supabase@27e6b1f)) * only create or update the email / phone identity after it's been verified ([supabase#1403](supabase#1403)) ([2d20729](supabase@2d20729)) * only create or update the email / phone identity after it's been verified (again) ([supabase#1409](supabase#1409)) ([bc6a5b8](supabase@bc6a5b8)) * unmarshal is_private_email correctly ([supabase#1402](supabase#1402)) ([47df151](supabase@47df151)) * use `pattern` for semver docker image tags ([supabase#1411](supabase#1411)) ([14a3aeb](supabase@14a3aeb)) ### Reverts * "fix: only create or update the email / phone identity after i… ([supabase#1407](supabase#1407)) ([ff86849](supabase@ff86849)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 15, 2024
## 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 supabase#1390
LashaJini
pushed a commit
to LashaJini/auth
that referenced
this pull request
Nov 15, 2024
🤖 I have created a release *beep* *boop* --- ## [2.139.2](supabase/auth@v2.139.1...v2.139.2) (2024-02-08) ### Bug Fixes * improve perf in account linking ([supabase#1394](supabase#1394)) ([8eedb95](supabase@8eedb95)) * OIDC provider validation log message ([supabase#1380](supabase#1380)) ([27e6b1f](supabase@27e6b1f)) * only create or update the email / phone identity after it's been verified ([supabase#1403](supabase#1403)) ([2d20729](supabase@2d20729)) * only create or update the email / phone identity after it's been verified (again) ([supabase#1409](supabase#1409)) ([bc6a5b8](supabase@bc6a5b8)) * unmarshal is_private_email correctly ([supabase#1402](supabase#1402)) ([47df151](supabase@47df151)) * use `pattern` for semver docker image tags ([supabase#1411](supabase#1411)) ([14a3aeb](supabase@14a3aeb)) ### Reverts * "fix: only create or update the email / phone identity after i… ([supabase#1407](supabase#1407)) ([ff86849](supabase@ff86849)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
ilike
which doesn't use the index onauth.identities.email
. Since the emails in theverifiedEmails
slice only contains lowercased emails, and theauth.identities.email
are also guaranteed to be lowercase, there is no need for a case-insensitive searchusers_email_partial_key
) in auth.users is defined on the condition thatis_sso_user = false
. However, the query usesis_sso_user is false
which causes it to not use the index ever (along withilike
). It would be much faster to dolower(email) = any (?)
rather thanemail ilike any (?)