#9519: Add QuerySet.bulk_delete() that issues only a single SQL query
-------------------------------------+-------------------------------------
     Reporter:  Tarken               |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:  database, queryset,  |      Needs documentation:  0
  delete                             |  Patch needs improvement:  0
    Has patch:  0                    |                    UI/UX:  0
  Needs tests:  0                    |
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 API idea: How about qs.values().delete() doing a no-signals delete? We
 could also implement the cascades by fetching the PK values to be deleted.
 This should make .values().delete() faster and less memory hungry, yet
 cascades are implemented.

 To me this API seems correct - values() is doing "fetch the raw values
 only, not objects" so values().delete() is doing "do the deletes by
 fetching raw values only, not objects".

 Currently .values().delete() doesn't work at all (except accidentally they
 do for fast-path deletes...).

 The disabling signals idea is dangerous if one can do global "signals
 disabled" call. For example "with disable_signals(): do_something()" will
 break `model.__init__` in do_something() for models having !ImageFields or
 !GenericForeignKeys. To be safe the only way to disable the signals should
 be by listing the signal target functions explicitly. In addition, the
 disabling should be thread-safe and really fast (at least for the no-
 signals-disabled case). `Model.__init__` is limited somewhat by
 signal.send speed already. So, my initial feeling is to not do this.

 I would love it if there was some way to tell the DB to set foreign key
 constraints to ON DELETE CASCADE temporarily. But, there doesn't seem to
 be any way to do this in SQL.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9519#comment:19>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to