#26194: WHERE EXISTS / WHERE NOT EXISTS clause without using QuerySet.extra
-------------------------------------+-------------------------------------
     Reporter:  john-parton          |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  closed
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:  QuerySet.extra       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by john-parton):

 Thanks for looking into this.

 Implementing a feature like `.filter(models.Exists(somerel__col=val))` as
 mentioned by akaariai in reference to #25789 would  fix my issue.

 I tried `Parent.objects.filter(child=None).distinct()` and it resulted in
 a query that was about 3 times as slow as the `NOT EXISTS` query. This is
 definitely better than my attempt with the subquery (which was about 2000
 times as slow), but it's still irksome that I can't easily compose the
 query using the ORM.

 I couldn't find #25789 because I was looking for tickets with the
 "QuerySet.extra" keyword. Can we add that keyword to #25789?

--
Ticket URL: <https://code.djangoproject.com/ticket/26194#comment:4>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/069.2b6b41b3436025c6a9e93647174011ca%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to