#23576: Fast-path deletion for MySQL
-------------------------------------+-------------------------------------
     Reporter:  jdufresne            |                    Owner:  nobody
         Type:  Uncategorized        |                   Status:  new
    Component:  Database layer       |                  Version:  1.7
  (models, ORM)                      |               Resolution:
     Severity:  Normal               |             Triage Stage:  Accepted
     Keywords:                       |      Needs documentation:  0
    Has patch:  0                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------
Changes (by akaariai):

 * stage:  Unreviewed => Accepted


Comment:

 The best advice I can give is to start from
 django/db/models/sql/subqueries.py and find update_can_self_select in
 there. You might be able to use a different compiler for the original
 query, one which does DELETE FROM <original query> instead of SELECT ...
 FROM <original query>.

 Note that even if you fix this, there are still cases where Django has to
 fetch the IDs to memory, then delete only those IDs. The reason is that
 Django needs to fire pre/post delete signals and cascade the deletion to
 dependent models. Especially for pre-delete signal the model must still
 exists in the database, so I don't see any other way than pre-fetch ids,
 then delete those ids.

 At least on PostgreSQL single query delete doesn't result in concurrency
 safe behavior. For example, it is possible that the view deletes the
 objects, another transaction commits an conflicting object, and then
 finally the view commits its objects -> unique constraint violation.

 I am marking this as accepted for allowing fast-path deletion for MySQL.

--
Ticket URL: <https://code.djangoproject.com/ticket/23576#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/067.47fdd8655765d5cd7b851fccbbdbebfd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to