#17535: list_detail call to len(queryset) should be queryset.exists()
--------------------------------------+------------------------------------
     Reporter:  hedleyroos@…          |                    Owner:  nobody
         Type:  Cleanup/optimization  |                   Status:  new
    Component:  Generic views         |                  Version:  1.3
     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
--------------------------------------+------------------------------------
Changes (by claudep):

 * needs_better_patch:   => 0
 * needs_docs:   => 0
 * needs_tests:   => 0
 * stage:  Unreviewed => Accepted


Comment:

 The code you mention is in deprecated code. Moreover, this  queryset
 evaluation is done in the non paginated section of the context build. The
 query, even if large, would be evaluated anyway later in the code. So this
 part seems a 'won't fix' for me.

 However, the issue is similar in the new class-based view code
 
(https://code.djangoproject.com/browser/django/trunk/django/views/generic/list.py#L116).
 And in this case, the len(queryset)==0 is done before the pagination take
 place. So this might be an issue.

 If you take the case of a costly query with not so many results, your
 proposal would call the query twice (once for exists and once for the real
 query), hence resulting in poorer performance when the query is not empty.
 Your solution might be better for a quick query that returns many results.
 The real solution would be probably to follow the same logic than the old
 function-based view and do this test later in the process
 (get_context_data).

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