fix(ownership-rules): Update email filter to create less conditions #92539
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.
Trying to improve the performance of this filter. The current implementation creates an OR condition and calls upper on both the column and the email of the condition for each email passed. This reduces it to a single IN check and a single usage of
upper
to do the case insensitive check.This tries to improve the performance of this query (the trace might not point to the correct span, it is the
db
span) by reducing the repeated work of callingUPPER
in so many conditions. Instead, I've updated the emails filter to annotate the queryset with the uppercased emails, then use the built in__in
lookup against the emails in an uppercased format.This breaks us away from the
in_iexact
helper that was there before, but that helper is what generates the large condition and there is no clean way to do the lookup with__in
in a case insensitive way that encapsulates the behaviour as cleanly.