#23646: query set sql update to change different values by different keys
-------------------------------------+-------------------------------------
     Reporter:  brillgen             |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |               Resolution:  wontfix
     Severity:  Normal               |             Triage Stage:
     Keywords:                       |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by shaib):

 On an old project, ~10 years ago and not Django based, we used a "bulk
 update" procedure that did:

 1) Bulk-insert the new records into a temporary table
 2) update in one statement using a join (SQL Server lets you do that)

 On hundreds of records, this was significantly faster than updating one-
 by-one (I no longer have access to any hard data, and it's irrelevant
 anyways).

 Anyway, I suspect a better API would involve passing a collection of
 objects and selecting just the fields to update:
 `Book.objects.update_many(books, 'price')`

--
Ticket URL: <https://code.djangoproject.com/ticket/23646#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.f774a0bce4298cd7eb4ac171bd7c060e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to