#34845: Slow query when using exclude
-------------------------------------+-------------------------------------
     Reporter:  Amin Aminian         |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  duplicate
     Keywords:  exclude,filter       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Amin, you haven't provided the full picture here.

 I'm not sure if you're using `FilteredRelation`, `extra`, or a third party
 application that does so explicitly for you but the ORM won't insert a
 `AND ("payment"."payable_type_id" = 30)` in the `JOIN` from a simple

 {{{#!python
 class Order(models.Model):
    pass

 class Payment(models.Model):
     order = models.ForeignKey(Order)

 qs = Order.objects.exclude(
     payment__isnull=True
 )
 }}}

 Something else is at play here and I'm pretty sure you are running into a
 lack of split exclude handling optimisations for `__null` when dealing
 with `FilteredRelation` or something else (e.g. third-party app) that
 makes use of it.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34845#comment:7>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018aa8b0bd22-5174bfe6-e372-4ba5-b744-a1b869f1c42a-000000%40eu-central-1.amazonses.com.

Reply via email to