On Sep 22, 8:59 pm, PlanetUnknown <[email protected]> wrote:
> Thanks Tom.
>
> But with this approach -
>
> > foo = Foo.objects.get(pk=foo_id)
> > foo.field = new_value
> > foo.save()
>
> There is an extra DB call, first the the data, and then another one to
> save it.
> If you have the primary_key with you, only one should suffice.
> I mean, when we step back and look at the whole scenario, there are
> thousand consumers doing this, and each has one extra DB call. That's
> pretty expensive.
>

Beware of hyper-optimizing. One extra database call per request is
almost insignificant.

Django's ORM is built to make the common use cases easier, and hence
make application development quicker (rather than necessarily more
efficient in terms of raw speed). The common use case is as Tom
describes. If you want to go outside that, there's nothing to stop
you, but you'll need to run custom SQL.
--
DR.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to