#17198: In admin results can be omitted due to pagination and inadequate 
ordering
clauses
-------------------------------+------------------------------------
     Reporter:  lukeplant      |                    Owner:  nobody
         Type:  Bug            |                   Status:  new
    Component:  contrib.admin  |                  Version:
     Severity:  Normal         |               Resolution:
     Keywords:                 |             Triage Stage:  Accepted
    Has patch:  0              |      Needs documentation:  0
  Needs tests:  0              |  Patch needs improvement:  0
Easy pickings:  0              |                    UI/UX:  0
-------------------------------+------------------------------------

Comment (by akaariai):

 I tested this on PostgreSQL 9.0. The only case where appending pk to the
 order by clause could have serious performance implications is if you
 have:
   - a lot of rows
   - an index on the sort_col
   - no index on sort_col, pk

 The test shows that in the above case you will get a limit 20 index scan
 if you order by the sort_col, but you will get a sequential scan + sort if
 you order by sort_col, pk. Now, if you have a lot of rows, the sort is
 going to be expensive. Of course, dropping the index on sort_col and
 creating a sort_col, pk index will solve that performance issue. If you
 don't have any index on the sort_col to begin with, you will get a seq
 scan + sort anyways.

 For a 100000 rows table I measured a difference of 1ms <-> 75ms. If you
 have million rows, then the difference was 1ms <-> 1 seconds. The
 difference is likely bigger if you have lots of columns (only 2 in the
 test). In the worst case you will need to do disk IO, and the difference
 will explode to much bigger numbers.

 The fix is an index on sort_col, pk in the rare cases where that is
 needed.

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