Closed some1ataplace closed 8 months ago
Using a .filter on email
requires PGSQL to unencrypt every single row in your table in order to make the comparison to your comparison value.
One workaround is to keep a hash on the email field using the HashField:
https://github.com/incuna/django-pgcrypto-fields#hash-based-fields
Then filter on the hash value instead of the encrypted value instead
my_model = MyModel.objects.filter(email_hashed__hash_of='me@example.com')
https://stackoverflow.com/questions/72642457/django-pgcrypto-fields-taking-long-time-to-load
https://stackoverflow.com/questions/62511078/django-postrgresql-performance-issues
Would like to have a discussion to see if there is anything we can all do to improve performance.