perf(db): index LOWER(email) for the case-insensitive account lookup (#876) - #884
Merged
Merged
Conversation
…876) Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
This file contains hidden or 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
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.
Closes #876
Migration
0068_users_email_lower_index: a non-unique index onLOWER(email), the predicateGetByEmailuses since #688. It's not unique on purpose: accounts written before #687 can be case-variant duplicates, and a unique index would fail the migration (and the boot with it) on such a database.docs/MIGRATIONS.mdgains the read-only query that lists those duplicates.Verification
Throwaway Postgres 18, server booted from this branch (AutoMigrate, then the SQL layer):
EXPLAIN ANALYZEof the exactGetByEmailquery, 20 002 rows:Duplicate report:
karim@alpha.test|2|{Karim@Alpha.test,karim@alpha.test}.Go gate
go build ./... && go vet ./... && go test ./... -race: BUILD_OK · VET_OK · TEST_OK, 80ok, 0FAIL. It ran with #882 applied temporarily, because master doesn't build (#881); that commit isn't part of this PR.Honest remainders
CREATE INDEX, which locks writes touserswhile it builds. That's milliseconds at today's sizes;CONCURRENTLYwould need its own non-transactional migration.