Re: isn't "insert into where not exists" atomic?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mage <mage(at)mage(dot)hu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: isn't "insert into where not exists" atomic?
Date: 2011-02-03 19:23:36
Message-ID: 26970.1296761016@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox
Thread:
Lists: pgsql-general

Mage <mage(at)mage(dot)hu> writes:
> The main question is that isn't "insert into ... select ... where not
> exists" atomic?

No, it isn't: it *will* fail in the presence of other transactions doing
the same thing, because the EXISTS test will only see rows that
committed before the command started. You might care to read the
manual's chapter about concurrency:
http://www.postgresql.org/docs/9.0/static/mvcc.html

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bob Price 2011-02-03 20:02:53 Re: how to avoid repeating expensive computation in select
Previous Message Scott Marlowe 2011-02-03 19:05:34 Re: upgrade