#10060: Multiple table annotation failure
----------------------------------------------+-----------------------------
          Reporter:  [email protected]  |         Owner:     
            Status:  new                      |     Milestone:     
         Component:  ORM aggregation          |       Version:  SVN
        Resolution:                           |      Keywords:     
             Stage:  Accepted                 |     Has_patch:  0  
        Needs_docs:  0                        |   Needs_tests:  0  
Needs_better_patch:  0                        |  
----------------------------------------------+-----------------------------
Comment (by bendavis78):

 Regarding the example sql queries in comment 9
 [http://code.djangoproject.com/ticket/10060#comment:9 above],  I've
 discovered that the first query is actually faster.  My database has grown
 fairly large in the past few months, so I've been able to test with more
 clear results (this is using MySQL, by the way).

 Using the JOIN method (where the aggregates are done in a derived join),
 the query was extremely slow.  It took over 30 minutes to execute with
 57,000 rows in the users table.   When I changed the query to the SELECT
 method (where the aggregates are done in a subquery in the select clause),
 the query took only 2 seconds with the exact same results.  I spent a
 whole day on this, and couldn't find a solid explanation for why the
 derived join method was taking so long.  I'd say at this point if anyone
 moves forward with fixing this bug we should put the aggregate in the
 subquery of the select clause.

 I've looked around for an official stance on how to write a query with
 multiple aggregations across different joined tables,  and haven't come up
 with a solid answer.  If anyone does find "the right way" to do it, I'd be
 interested to know -- I think that definitely needs to be settled before
 this bug can be fixed.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/10060#comment:16>
Django <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to