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

Comment (by Akash Kumar Sen):

 Replying to [comment:33 Mariusz Felisiak]:
 > Have you checked all comments and how it actually works? `delete()`
 collects objects PKs (direct and related), deletes, sends signals, etc.
 This issue is about adding `bulk_delete()` method which will bypass all
 these steps and perform `DELETE` based on the queryset filters.

 I tried to compare the number of queries with the analogy of
 {{{bulk_create}}} . But now the need seems reasonable, will try to create
 a patch with the following tasks performed.

 1. Introduce a new method called bulk_delete() in the QuerySet API.
 2. The bulk_delete() method should operate on the queryset and issue a
 single SQL query for deletion.
 3. The deletion should respect the previous query operations performed on
 the queryset(or take them as kwargs) such as filters and extra conditions.
 4. To optimize performance, the bulk_delete() method can take advantage of
 a "fast-path" deletion, similar to the existing delete operation and
 should not send any signals to avoid unnecessary overhead.
 5. If cascading deletes are needed, the bulk_delete() method should handle
 them by fetching only the necessary values from the database, without
 instantiating full objects.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/9519#comment:34>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018851f6064d-d8231944-4c1d-4472-8607-520612846ddf-000000%40eu-central-1.amazonses.com.

Reply via email to