On Wed, Jul 24, 2013 at 5:39 PM, Carsten Fuchs <carsten.fu...@cafu.de> wrote: > Hi all, > > Am 15.07.2013 17:41, schrieb Carsten Fuchs: > >> we have two queries/QuerySets Q_a and Q_b, each of which use INNER joins >> in the generated SQL when evaluated individually. >> >> When I use a Q object to "OR" these two QuerySets, the INNER joins turn >> into LEFT OUTER joins -- which in turn cause a huge performance drop >> (several hundred times slower than with INNER joins). >> >> Why is this, and can I do anything against it at the Django ORM level? > > > > Can someone provide some help or insights into this, please? >
Isn't this to be expected? You've asked Django to OR the querysets. This means that you are looking for tuples from STAFF where either the join+conditions to ERFASST match or the join+conditions to STAFF_BEREICHE match. If these joins were performed with an INNER JOIN, then the query would only include tuples from STAFF that match both joins and conditions. Cheers Tom -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.