Opened 18 years ago

Closed 13 years ago

Last modified 12 years ago

#661 closed enhancement (wontfix)

New function: batch save of objects would make for more efficient processing

Reported by: Lllama Owned by: Adrian Holovaty
Component: Core (Other) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently new records are saved one at the time using save(). In most cases this is sufficient though a batch save method would allow for more efficient database access when appropriate.

An example: An app allows the upload of a file which is parsed into many records. Currently each record would have to be looped over and save()d. A function which took the list of records and did One Big Insert would make the operation more efficient.

Change History (5)

comment:1 by hugo, 18 years ago

actually even when collecting stuff you need to do separate inserts, as every record corresponds to one row in the database and such requires one insert. Things like COPY FROM aren't standard and so shouldn't really be used. And with transactions you will have "bundled updates" anyway, as the database internally handles when to move stuff into the tables.

comment:2 by Adrian Holovaty, 18 years ago

Resolution: wontfix
Status: newclosed

This is outside the scope of Django -- feel free to use your database server's batch save functionality, such as COPY FROM.

comment:3 by speedplane, 13 years ago

Resolution: wontfix
Status: closedreopened

This would really nice to fix. At least as a feature request. Could you take another look at this. Take a look at what some people are doing:

http://code.google.com/p/django-batchimport
http://stackoverflow.com/questions/1136106/efficent-way-to-insert-thousands-of-records-into-a-table-sqlite-python-django
http://stackoverflow.com/questions/2252530/efficent-way-to-bulk-insert-with-get-or-create-in-django-sql-python-django
http://www.answerspice.com/c119/1483019/how-do-i-perform-a-batch-insert-in-django

I would also say that this is within the scope of django. The idea is to use as little SQL as possible (ideally none).

comment:4 by Paul McMillan, 13 years ago

Needs documentation: set
Resolution: wontfix
Status: reopenedclosed

While I agree that this might be useful functionality, re-opening a ticket which was closed by a core dev as "wontfix" (even when that was 4 years ago) isn't the way to get your request considered. Instead, you should start a thread about it on the django-dev mailing list.

Please review the documentation about how we use Trac:

http://docs.djangoproject.com/en/dev/internals/contributing/#triage-by-the-general-community

I'm re-closing this ticket.

comment:5 by Karen Tracey, 12 years ago

Easy pickings: unset
UI/UX: unset

Just a note, while this one was closed wontfix the request was made again in #7596 and that one was fixed.

Note: See TracTickets for help on using tickets.
Back to Top