#6785: QuerySet.get() should only attempt to fetch a limited number of rows
-------------------------------------+-------------------------------------
     Reporter:  deadwisdom           |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  master
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Accepted
     Severity:  Normal               |      Needs documentation:  0
     Keywords:                       |  Patch needs improvement:  0
    Has patch:  1                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by shai):

 Replying to [comment:8 akaariai]:
 > Limiting the fetches doesn't work that well on most core databases.
 [...] [T]he overhead of generating all the rows in the database and
 transferring the results would still be there.
 >
 > To get rid of clone() overhead we could just call query.set_limits()
 manually.
 >
 > With this all being said... I guess we are optimizing the wrong case
 here. Successful .get() (just one row returned) should be optimized, not
 the error case. I am not sure how much overhead LIMIT (or the nested
 selects on Oracle) cost.

 The intent of re-opening is exactly to optimize the successful case; the
 issue is that the current implementation imposes an overhead on all
 `get()` calls for better handling of the error case. Doing it with fetches
 alone will remove this overhead -- for the successful case, asking for 21
 results or for all results would be the same. I am not sure about the
 added performance costs either, except that (as noted) the nested selects
 on Oracle cost us in functionality.

 On a side note, if more than one row is returned from the database, no
 model instance at all needs to be created.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/6785#comment:9>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.23aca87697a4b8dd7efa5161eadc5aeb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to