#34597: Queryset (split) exclude's usage of Exists is significantly slower than
subquery
-------------------------------------+-------------------------------------
     Reporter:  Lorand Varga         |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  Database layer       |                  Version:  3.2
  (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 David Sanders):

 Posting some investigation here for charettes & others:

 I suspect the additional redundant condition in the inner query that
 references the outer query is causing unwanted materialisation:

 {{{
 AND "test_app_blog"."id" = "test_app_blog"."id"
 }}}

 When I removed this – no more materialisation.

 Additionally: Not sure why this is being added to the query but if you
 remove `Q(is_published=True)` so that you simply have
 `Blog.objects.filter(~Q(translation=None))` then this redundant condition
 is no longer added.

 I tested with the reporter's models on latest main & I'd wager this is
 something we can/may want to address.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34597#comment:6>
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/010701886759459a-1166cf32-bf45-4c27-92a2-d990be3d21e0-000000%40eu-central-1.amazonses.com.

Reply via email to