#25789: Inefficient Queries Generated due to not using WHERE EXISTS
-------------------------------------+-------------------------------------
     Reporter:  cancan101            |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  1.8
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by akaariai):

 Yes, this is possible, and something Django's ORM should do.

 Unfortunately this is hard to implement correctly. The big problem is
 aggregation, when doing .filter().annotate(), where both operations target
 the same relation, the aggregation must use results of the join generated
 by the filter. But if the filter doesn't generate a join, then we have a
 problem.

 It would be Djangoic if the exists query would be generated automatically.
 For the above mentioned reason this is hard. Maybe it would be easier if
 we had something like .filter(models.Exists(somerel__col=val)), where the
 Exists() class would inform Django that an exists subquery should be
 generated.

--
Ticket URL: <https://code.djangoproject.com/ticket/25789#comment:2>
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.a3d4072c91b65ca466472d6ade97278b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to