﻿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
36490	Avoid unnecessary transaction in QuerySet.bulk_create	Simon Charette	Simon Charette	"The QuerySet.bulk_create method creates an unnecessary transaction when it can perform the insert in a singe `INSERT` when the following criteria are met

1. There's no mix of objects with and without primary key (this could potentially be optimized to be done in a single query but that's another can of worm)
2. The objects fit in a single batch with respect to the provided `batch_size` and `connection.ops.bulk_batch_size`

This is unnecessary overhead we've optimized in other areas of the code base (e.g. `Model.save`) which seems warranted in this case particularly because `bulk_create` offers a more featureful interface than `create` [https://johnnymetz.com/posts/postgresql-failing-insert/ which can be used to insert a small number of rows]."	Cleanup/optimization	closed	Database layer (models, ORM)	5.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
