Changes between Version 1 and Version 2 of Ticket #35778, comment 11


Ignore:
Timestamp:
Oct 2, 2024, 12:12:21 PM (6 weeks ago)
Author:
Simon Charette

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35778, comment 11

    v1 v2  
    1515Then the resulting index will be on `(phone_number)::text` and queries of the form `filter(phone_number__startswith="123")` will generate `WHERE (phone_number)::text LIKE '123%'` will be able to use the index.
    1616
    17 If we change `Cast` to use `CAST` instead of `::` are confident that the Postgres planer will be smart enough to use the pre-existing `(phone_number)::text` it for queries of the form `CAST(phone_number AS text) LIKE '123%'`? From past experience the expression has to exactly match for the planner to consider the index and we can't expect users to rebuild all of their indices every time they upgrade their Django version.
     17If we change `Cast` to use `CAST` instead of `::` I'm not entirely confident that the Postgres planer will be smart enough to use the pre-existing `(phone_number)::text` it for queries of the form `CAST(phone_number AS text) LIKE '123%'`. From past experience the expression has to exactly match for the planner consider the index as candidate so unless `(expr)::type` and `CAST(expr AS type)` result in the same AST I doubt we can safely change it without forcing users to rebuild all of their indices making use of `Cast` which seems way beyond the scope of this ticket.
Back to Top