"""
Hmmmm, that is not ideal behavior. You mean QuerySet.delete() calls
the signal for each deleted object, rather than doing a delete at the
database level?
"""

This might not be exactly accurate, but I think it goes something like this:
  - Fetch all the to-be deleted objects (one query)
  - Check if there are cascades for those objects, fetch the cascades (one 
query per cascaded Model class?)
  - Send pre_delete signals for all deleted instances
  - Do the delete as one query for the to-be deleted objects, and then one 
query(?) per cascade Model class
  - Send post_delete signals

Now, this is not that inefficient - but it would be a good optimization to NOT 
fetch the instances if there are no listeners for pre/post delete signals and 
there are no cascades (or all cascades are DO_NOTHING). Even if there are 
cascades, you could fetch just PKs of the to-be deleted models (even that is 
not actually needed, as you can use joins)

Again: I am not 100% sure how this behaves...

 - Anssi

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to