File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -341,8 +341,13 @@ it on a ``QuerySet`` by calling
341341
342342Adding an index to your database may help to improve ordering performance.
343343
344- Insert in bulk
345- ==============
344+ Use bulk methods
345+ ================
346+
347+ Use bulk methods to reduce the number of SQL statements.
348+
349+ Create in bulk
350+ --------------
346351
347352When creating objects, where possible, use the
348353:meth:`~django.db.models.query.QuerySet.bulk_create()` method to reduce the
@@ -362,8 +367,13 @@ Note that there are a number of :meth:`caveats to this method
362367<django.db.models.query.QuerySet.bulk_create>`, so make sure it's appropriate
363368for your use case.
364369
365- This also applies to :class:`ManyToManyFields
366- <django.db.models.ManyToManyField>`, so doing::
370+ Insert in bulk
371+ --------------
372+
373+ When inserting objects into :class:`ManyToManyFields
374+ <django.db.models.ManyToManyField>`, use
375+ :meth:`~django.db.models.fields.related.RelatedManager.add` with multiple
376+ objects to reduce the number of SQL queries. For example::
367377
368378 my_band.members.add(me, my_friend)
369379
You can’t perform that action at this time.
0 commit comments