Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #35194 -- Fixed case-insensitive operations in GeneratedFields on Postgres 15.6+. #18085

Closed
wants to merge 1 commit into from

Conversation

sarahboyce
Copy link
Contributor

Trac ticket number

ticket-35194

Branch description

Postgres >= 12.18, 13.14, 14.11, 15.6, 16.2 changed the way the immutability of generated and default expressions is detected in postgres/postgres@743ddaf.

This reverts the optimization of using UPPER instead of ILIKE for postgres case-insensitive comparisons as UPPER can return different value depending on the collation and thus is not immutable.

See: https://code.djangoproject.com/ticket/3575

I can see a StackOverflow discussion on how using LOWER/UPPER LIKE is faster than using ILIKE by roughly ~17%, however the advice is also "just use an index".

So....

  • Do we think this is a viable solution to the problem?
  • If yes, should I note/document the potential performance regression to case-insensitive un-index-ed Postgres queries in the release note?

I guess users could chose to use upper/lower themselves to achieve what we were doing in the background if they experience a performance regression and do not want to use an index 🤔

Checklist

  • This PR targets the main branch.
  • The commit message is written in past tense, mentions the ticket number, and ends with a period.
  • I have checked the "Has patch" ticket flag in the Trac system.
  • I have added or updated relevant tests.
  • I have added or updated relevant docs, including release notes if applicable.

@sarahboyce sarahboyce force-pushed the ticket_35194 branch 2 times, most recently from 85e60c8 to b26146f Compare April 18, 2024 08:38
…on Postgres 15.6+.

Postgres >= 12.18, 13.14, 14.11, 15.6, 16.2 changed the way the immutability
of generated and default expressions is detected in postgres/postgres@743ddaf.

This reverts the optimization of using UPPER instead of ILIKE for postgres
case-insensitive comparisons as UPPER can return different value depending on
the collation and thus is not immutable.

Refs django#3575.

Thanks Aldalen for the report.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant