Fixed #18676 -- Allow fast-path deletion of objects

Objects can be fast-path deleted if there are no signals, and there are
no further cascades. If fast-path is taken, the objects do not need to
be loaded into memory before deletion.

Thanks to Jeremy Dunck, Simon Charette and Alex Gaynor for reviewing
the patch.
This commit is contained in:
Anssi Kääriäinen 2012-09-20 18:51:30 +03:00
parent 3fcca0e947
commit 1cd6e04cd4
13 changed files with 275 additions and 19 deletions

View file

@ -529,6 +529,14 @@ class QuerySet(object):
self._result_cache = None
delete.alters_data = True
def _raw_delete(self, using):
"""
Deletes objects found from the given queryset in single direct SQL
query. No signals are sent, and there is no protection for cascades.
"""
sql.DeleteQuery(self.model).delete_qs(self, using)
_raw_delete.alters_data = True
def update(self, **kwargs):
"""
Updates all elements in the current QuerySet, setting all the given