On 5/16/06, Elver Loho <[EMAIL PROTECTED]> wrote:
> Let's take the poll sample. We've got the vote() view going on.
>
> choice.votes += 1
> choice.save()
>
> Suppose we've got thread1 and thread2 going on (high-load website):
>
> choice.votes is originally 16
>
> thread1.choice.votes += 1
> thread2.choice.votes += 1
> thread1.choice.save()
> thread2.choice.save()
>
> choice.votes _should_ be 18 now, but is it 18 or 17?

You're right to point this out -- it'll probably be 17. That
particular example is a bad example; it'd be better to do "UPDATE
choices SET votes=votes+1 WHERE id=X", which would always increment
rather than setting the value directly.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to