Opened 6 hours ago
Last modified 3 hours ago
#36690 new Uncategorized
Use case for EXTRA()
| Reported by: | Gareth Leake | Owned by: | |
|---|---|---|---|
| Component: | Uncategorized | Version: | 5.2 |
| Severity: | Normal | Keywords: | QuerySet.extra |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
Django's ORM leverages UPPER() and casts to text UPPER(...)::text when doing a case insensitive search. This is not adequately performant for our use case, and loses the use of an index due to the UPPER() call. The extra() function allows me to explicitly make a case insensitive ILIKE call on postgres.
Note:
See TracTickets
for help on using tickets.
I found ticket #3575, which reported that using
ILIKEin postgres is inefficient, and the solution changed the SQL from usingILIKEtoUPPER. Sinceextra()is planned for deprecation, could the query be achieved by implementing aFuncforILIKEinstead?