On Thu, Feb 5, 2009 at 3:09 PM, George Sakkis <george.sak...@gmail.com>wrote:
> > Hello, > > I am looking at the raw sql executed when I run a delete or update on > a QuerySet and it appears that it does a redundant "select *" for the > queryset before the actual delete/update. For example > > delete_ids = (108, 107, 106) > qs = MyModel.objects.filter(pk__in=delete_ids) > print connection.queries # shows no queries > qs.delete() > print connection.queries # shows two queries, a select followed by a > delete > > Am I missing something or Is this supposed to work like this, and if > so why ? > > George > > > No you are correct, and this intended behavior. This is because Django emulates the CASCADE behavior for DBs which don't support it, so it needs to build up the list of related objects internally, to do this it needs the objects themselves. To get a better idea of what I'm describing take a look at the source: http://code.djangoproject.com/browser/django/trunk/django/db/models/query.py#L409 Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---