Re: Question: update and transaction isolation - Mailing list pgsql-hackers

From mlw
Subject Re: Question: update and transaction isolation
Date
Msg-id 3CAB3697.A335DDC8@mohawksoft.com
Whole thread Raw
In response to Re: Question: update and transaction isolation  (Peter Eisentraut <peter_e@gmx.net>)
Responses Re: Question: update and transaction isolation  (Peter Eisentraut <peter_e@gmx.net>)
Re: Question: update and transaction isolation  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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?


pgsql-hackers by date:

Previous
From: Justin Clift
Date:
Subject: Re: ANALYZE after restore
Next
From: mlw
Date:
Subject: Re: Suggestions please: names for function cachability