summaryrefslogtreecommitdiff
path: root/docs/ref
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2011-09-09 19:22:28 +0000
committerAlex Gaynor <alex.gaynor@gmail.com>2011-09-09 19:22:28 +0000
commit7deb25b8dd5aa1ed02b5e30cbc67cd1fb0c3d6e6 (patch)
tree09ed3208f309d71b5710b8287bccdb92ddf40c58 /docs/ref
parente55bbf4c3c42b17d52c21bc3a460b4981fdc190c (diff)
Fixed #7596. Added Model.objects.bulk_create, and make use of it in several places. This provides a performance benefit when inserting multiple objects. THanks to Russ for the review, and Simon Meers for the MySQl implementation.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16739 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/ref')
-rw-r--r--docs/ref/models/querysets.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt
index b2c521e645..898306d67d 100644
--- a/docs/ref/models/querysets.txt
+++ b/docs/ref/models/querysets.txt
@@ -1158,6 +1158,29 @@ has a side effect on your data. For more, see `Safe methods`_ in the HTTP spec.
.. _Safe methods: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1
+bulk_create
+~~~~~~~~~~~
+
+.. method:: bulk_create(objs)
+
+This method inserts the provided list of objects into the database in an
+efficient manner (generally only 1 query, no matter how many objects there
+are)::
+
+ >>> Entry.objects.bulk_create([
+ ... Entry(headline="Django 1.0 Released"),
+ ... Entry(headline="Django 1.1 Announced"),
+ ... Entry(headline="Breaking: Django is awesome")
+ ... ])
+
+This has a number of caveats though:
+
+ * The model's ``save()`` method will not be called, and the ``pre_save`` and
+ ``post_save`` signals will not be sent.
+ * It does not work with child models in a multi-table inheritance scenario.
+ * If the model's primary key is an :class:`~django.db.models.AutoField` it
+ does not retrieve and set the primary key attribute, as ``save()`` does.
+
count
~~~~~