Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Christopher Kings-Lynne
> > 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 read committed level, if the second update launches before the first > update

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Hiroshi Inoue
Tom Lane wrote: > > Peter Eisentraut <[EMAIL PROTECTED]> writes: > > Tom Lane writes: > To my mind, full SERIALIZABLE mode is the only approach that can be > explained in terms of simple notions like "you see only the data that > existed at time T". There's another way. If the current value is d

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Tom Lane
Peter Eisentraut <[EMAIL PROTECTED]> writes: > Tom Lane writes: >> The reason it works in read-committed mode is that the second guy to >> arrive at the row will observe that the row has an update in progress; >> will block waiting for the previous updater to commit or abort; and if >> commit, wil

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Peter Eisentraut
Tom Lane writes: > The reason it works in read-committed mode is that the second guy to > arrive at the row will observe that the row has an update in progress; > will block waiting for the previous updater to commit or abort; and if > commit, will use the updated version of the row as the starti

[HACKERS] Question: update and transaction isolation

2002-04-03 Thread mlw
Take this update statement: 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? I am assumed that foo will always be correct and that the database will manage any contention, but wh

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Tom Lane
mlw <[EMAIL PROTECTED]> writes: > 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 = counte

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Peter Eisentraut
mlw writes: > 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 read committed level, if the second update launches before the first update is fini

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread mlw
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 mi

Re: [HACKERS] Question: update and transaction isolation

2002-04-03 Thread Peter Eisentraut
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 probl

[HACKERS] Question: update and transaction isolation

2002-04-03 Thread mlw
Take this update statement: 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? I am assumed that foo will always be correct and that the database will manage any contention, but w