Code

Opened 9 years ago

Closed 4 years ago

Last modified 3 years ago

#661 closed enhancement (wontfix)

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

Reported by: Lllama Owned by: adrian
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.

Attachments (0)

Change History (5)

comment:1 Changed 9 years ago by hugo

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 Changed 8 years ago by adrian

  • Resolution set to wontfix
  • Status changed from new to closed

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

comment:3 Changed 4 years ago by speedplane

  • Resolution wontfix deleted
  • Status changed from closed to reopened

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 Changed 4 years ago by PaulM

  • Needs documentation set
  • Resolution set to wontfix
  • Status changed from reopened to closed

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 Changed 3 years ago by kmtracey

  • 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.