#20880: Split clone() to clone() and pre_next_op()
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    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:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 I updated (force-pushed) to
 https://github.com/akaariai/django/tree/splitted_clone. The patch is
 pretty good (cleanup needed), and shows promising results for model saving
 and some other queryset operations:
 {{{
 Running 'model_save_existing' benchmark ...
 Min: 0.014001 -> 0.010278: 1.3622x faster
 Avg: 0.014304 -> 0.010394: 1.3763x faster
 Significant (t=37.226713)


 Running 'model_save_new' benchmark ...
 Min: 0.013848 -> 0.010196: 1.3582x faster
 Avg: 0.014079 -> 0.010408: 1.3527x faster
 Significant (t=20.503974)


 Running 'query_get' benchmark ...
 Min: 0.027801 -> 0.023326: 1.1918x faster
 Avg: 0.028116 -> 0.023599: 1.1914x faster
 Significant (t=31.307197)
 }}}

 For qs_filter_chaining (~5 .filter() calls) using inplace results in
 speedup of:
 {{{
 Running 'qs_filter_chaining_inplace' benchmark ...
 Min: 0.000892 -> 0.000553: 1.6132x faster
 Avg: 0.000937 -> 0.000571: 1.6424x faster
 Significant (t=16.654697)
 }}}

 This is by no means complex query, yet it shows promising results.

 So, it is worth considering if .inplace() should be public API. If so,
 then it would make sense to guard against using stale versions of the
 queryset. This is doable by cloning the outer QuerySet. Skipping cloning
 of the internal Query, should give most of the speedup.

 Another consideration is that if the ._clone() should be renamed to
 ._copy() or something. The patched version ._clone() does subtly different
 thing than the old version, so this might cause some grey hairs for those
 who use that internal API.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/20880#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 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/066.394ea28a41a2d9dbfab873f72fc27973%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to