#9166: stupid SQL
---------------------------------------------------+------------------------
          Reporter:  [EMAIL PROTECTED]                   |         Owner:  
nobody    
            Status:  closed                        |     Milestone:  post-1.0  
         Component:  Database layer (models, ORM)  |       Version:  1.0       
        Resolution:  wontfix                       |      Keywords:  STUPID SQL
             Stage:  Unreviewed                    |     Has_patch:  0         
        Needs_docs:  0                             |   Needs_tests:  0         
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by mtredinnick):

  * status:  new => closed
  * resolution:  => wontfix

Comment:

 This rapidly gets very, very difficult once you have more than one related
 model, because adding all the fields to select leads to selecting N * M
 rows, if there are N rows in the first related table and M in the second
 (instead of N + M + 1 rows, which is the ideal). The `select_related()`
 processing is already fairly complex, so this isn't a trivial change. When
 somebody writes a solid patch to improve it, we'll certainly accept it.

 There's already a ticket open to add similar "follow reverse relations"
 for `select_related()` and #7270 handles the special case of reverse
 !OneToOneFields (which is the one case where multiple rows won't be
 returned).

 It isn't stupid SQL, it's a conscious decision to avoid a very bad
 performance overhead. The same effect can be achieved in almost all cases
 (including the above one) by turning the second queryset around to be a
 query on the Translation table using the book ids that you already know,
 so it's two queries not 101.

 "Wontfixing" this ticket, since the behaviour is documented and
 intentional. If somebody writes a patch to make things better, it can be
 attached to a ticket at that time.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/9166#comment:2>
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