Tuesday, October 29, 2013

Re: Django Transactions Performance increase

On Tue, Oct 29, 2013 at 4:29 PM, Robin Fordham <gingebot@gmail.com> wrote:
> What do you mean by this?
>
> By the nature of the data coming in it is pre validated, so I know already
> that row[0] is a valid id, row[1] is a valid foo value, row[2] is a valid
> baa value.
>

In case you were simplifying the example for the list, and what you
actually needed to do was this:

for row in updatedata:
obj = Object.objects.get(id=row[0])
obj.foo = run_some_calculation(obj, row[1])
obj.baa = row[2]
obj.save()

eg, so you required the object itself. If that was the case, you would
still get benefit from loading multiple objects at once, since you
would issue less queries. However, to do so would require some magic
in order to chunk updatadata into sets small enough to load all at
once, ~10,000 objects at a time. (magic ommitted :)

Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFHbX1JuWz9GBU3ezSp737Ywa-6zK_DafYva6jbiR82BiQy1ww%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment