Skip to content

Optimize finger property case insensitive queries with an upper case index

Alain St-Denis requested to merge astdenis/optimise_finger_queries into master

The use of __iexact results in a SQL query that uses the UPPER function which prevents the use of the default index (as per https://blog.gitguardian.com/10-tips-to-optimize-postgresql-queries-in-your-django-project/). This has been confirmed using the explain method on a queryset for finger__iexact.

The addition of a custom index that applies the UPPER function on record creation improves the time to query by a significant factor.

Merge request reports