﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
20880	Split clone() to clone() and pre_next_op()	Anssi Kääriäinen	nobody	"QuerySet and Query clone() methods are doing more than just cloning, they are also doing set up for next operation, changing the class of the clone if requested, and even throwing away some attribute values.

To make the code a bit more readable the clone() the preparation for next op should be splitted away to pre_next_op() method. This also allows creating inplace querysets that work precisely like full-clone querysets (inplace queryset doesn't do cloning at all). This again allows speeding up certain internal operations (like model.save() and prefetch_related()), and also allows users to optimise heavy-to-create querysets by avoiding clone() overhead.

Patch available from https://github.com/akaariai/django/tree/splitted_clone. The inplace queryset used for Model.save_base() speeds up model.save() by about 20% for a simple m = Model.objects.get(); m.save() benchmark. There are other places where similar optimisations could be used. Prefetch speedup is tracked in ticket #20577."	Cleanup/optimization	new	Database layer (models, ORM)	dev	Normal				Unreviewed	0	0	0	0	0	0
