﻿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
35904	Speed up fixture loading by adding options bulk insert/create	JorisBenschop		"As per    [https://forum.djangoproject.com/t/feature-proposal-faster-fixture-loading-via-loaddata-command/36972  ​this forum discussion], I have created a patch to improve load times for the loaddata command under some circumstances.

Currently the “loaddata” management command uses the obj.save() method for each deserialized object within a fixture. This function first tries an UPDATE statement and, if that fails, tries an INSERT statement. By using the --force_insert a reduction of 50% of queries is achieved. 

A second option is to use bulk_create for insertion of multiple records. This improves insertion speed by (n-1/n), or ~99% for insertion of 100 records. 

These options are not meant to cover each use case, and therefore are set to optional.

Benchmark results
===============
test is to insert 1000 records from a single fixture
current: 0.116s
with --force_insert: 0.066s
with --bulk_create: 0.01s

test is to insert 10000 records from a single fixture
current: 1.07s
with --force_insert: 0.39s
with --bulk_create: 0.010s





"	New feature	new	Testing framework	5.0	Normal				Unreviewed	1	0	0	0	0	0
