#28477: Strip unused annotations from count queries
-------------------------------------+-------------------------------------
     Reporter:  Tom Forbes           |                    Owner:  Simon
         Type:                       |  Charette
  Cleanup/optimization               |                   Status:  closed
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Dustin, [https://forum.djangoproject.com/t/django-4-2-behavior-change-
 when-using-arrayagg-on-unnested-arrayfield-postgresql-specific/21547/2 I
 think this answer is your way out].

 Basically the optimization should be disabled for any set-returning
 function but since Django only has single native one,`Subquery`, so the
 optimization is only disabled when the `subquery = True` attribute is set.

 In order to truly solve this issue I think we should introduce a new
 documented `Expression.set_returning: bool` (better name welcome!) flag
 that defaults to `False` but is set to `True` for `Subquery`.

 The root of this problem is that the ORM simply doesn't support functions
 that return rows in a generic way. Instead it branches out using
 `getattr(expr, "subquery", False)` in all cases that it makes the most
 sense to support them (e.g. `__in` looups).

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28477#comment:23>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070189294c5e6f-1f144466-4c38-48cd-8ca3-a9da2e693ca8-000000%40eu-central-1.amazonses.com.

Reply via email to