You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Index Scan using ix_auth_user_email on auth_user (cost=0.14..2.36 rows=1 width=1245) (actual time=0.044..0.045 rows=0 loops=1)
Index Cond: ((email)::text = '[email protected]'::text)
Thank you for raising this, @stephane! That's indeed a welcome optimization.
My preference would go for 2, i.e. create a functional index.
I prefer not to rely on custom extension, especially since CIText looks only designed for PostgreSQL.
As for storing the e-mail in lower-case, this is a debate we had some time ago and we purposefully chose to store the e-mails case-sensitive but query them case-insensitive.
If you agree with this, I would be happy to review a PR that creates a lowercased index for e-mails 🙂
Describe the bug
An index is created on the
email
field:https://github.com/fastapi-users/fastapi-users-db-sqlalchemy/blob/main/fastapi_users_db_sqlalchemy/__init__.py#L61
but the index can't be used by the
get_by_email()
method because the filtering uses a function on the SQL field.To Reproduce
Sequential scan is used instead of index scan.
Expected behavior
There is several ways to fix the issue:
CREATE INDEX ix_auth_user ON auth_user (lower(email) text_pattern_ops);
I can provide a PR when we'll agree on a solution.
Configuration
The text was updated successfully, but these errors were encountered: