#15116: Don't ORDER BY when using .in_bulk()
---------------------------------------------------+------------------------
          Reporter:  lamby                         |         Owner:  nobody
            Status:  new                           |     Milestone:        
         Component:  Database layer (models, ORM)  |       Version:  1.2   
        Resolution:                                |      Keywords:        
             Stage:  Ready for checkin             |     Has_patch:  1     
        Needs_docs:  0                             |   Needs_tests:  0     
Needs_better_patch:  0                             |  
---------------------------------------------------+------------------------
Changes (by lukeplant):

  * stage:  Design decision needed => Ready for checkin

Comment:

 We certainly don't want to start throwing exceptions (Option 1) because
 there happens to be an ordering on the queryset - the semantics of
 `in_bulk()` make it obvious that ordering becomes irrelevant, but not that
 ordering is illegal. The assertion is thrown for limit/offset because the
 method would return incorrect results otherwise, due to the adding of the
 filter.

 Option 1 would add the overhead of a `SortedDict` (which is significant),
 and it would probably do this in most cases, because most querysets will
 inherit a default ordering from the Model. If people need ordering, they
 have other options. So option 2 - the original patch - seems by far the
 best option.  Tests/docs not needed, since this is a performance tweak
 that is virtually impossible to test, and we already have at least one
 test that will check with `in_bulk()` still works.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/15116#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 django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to