Re: Question: update and transaction isolation

From: mlw <markw(at)mohawksoft(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Question: update and transaction isolation
Date: 2002-04-03 17:06:31
Message-ID: 3CAB3697.A335DDC8@mohawksoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut wrote:
>
> mlw writes:
>
> > update mytable set foo=foo+1 where bar='xxx';
> >
> > If that gets executed more than once at the same time by multiple instances of
> > postgresql. Will foo ever lose a count?
>
> No, but if you run this in read committed isolation mode then you might
> get into non-repeatable read type problems, i.e., you run it twice but
> every foo was only increased once. If you use serializable mode then all
> but one concurrent update will be aborted.

I'm not sure you answered my question. Let me put it to you like this:

Suppose I wanted to make a table of page counts, like this:

create table pagecounts (counter int4, pagename varchar)

For each page hit, I do this:

update pagecounts set counter = counter + 1 where pagename = 'testpag.php'

Do I have to set a particular isolation level? Or does this not work in
general?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-04-03 17:10:42 Re: Suggestions please: names for function cachability
Previous Message Justin Clift 2002-04-03 17:06:02 Re: ANALYZE after restore