diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2011-09-09 19:22:28 +0000 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2011-09-09 19:22:28 +0000 |
commit | 7deb25b8dd5aa1ed02b5e30cbc67cd1fb0c3d6e6 (patch) | |
tree | 09ed3208f309d71b5710b8287bccdb92ddf40c58 /django/db/backends/postgresql_psycopg2/operations.py | |
parent | e55bbf4c3c42b17d52c21bc3a460b4981fdc190c (diff) | |
download | django-7deb25b8dd5aa1ed02b5e30cbc67cd1fb0c3d6e6.tar.gz |
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 'django/db/backends/postgresql_psycopg2/operations.py')
-rw-r--r-- | django/db/backends/postgresql_psycopg2/operations.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py index d535ee316f..c3a23c2073 100644 --- a/django/db/backends/postgresql_psycopg2/operations.py +++ b/django/db/backends/postgresql_psycopg2/operations.py @@ -180,3 +180,7 @@ class DatabaseOperations(BaseDatabaseOperations): def return_insert_id(self): return "RETURNING %s", () + + def bulk_insert_sql(self, fields, num_values): + items_sql = "(%s)" % ", ".join(["%s"] * len(fields)) + return "VALUES " + ", ".join([items_sql] * num_values) |