Re: Simple Atomic Relationship Insert - Mailing list pgsql-general

From Thomas Kellerer
Subject Re: Simple Atomic Relationship Insert
Date
Msg-id m94885$aqq$1@ger.gmane.org
Whole thread Raw
In response to Re: Simple Atomic Relationship Insert  (Brian Dunavant <brian@omniti.com>)
Responses Re: Simple Atomic Relationship Insert
List pgsql-general
Brian Dunavant wrote on 13.01.2015 22:33:
> What issue are you having?  I'd imagine you have a race condition on
> the insert into hometowns, but you'd have that same race condition in
> your app code using a more traditional 3 query version as well.
>
> I often use CTEs like this to make things atomic.  It allows me to
> remove transactional code out of the app and also to increase
> performance by reducing the back-and-forth to the db.
> http://omniti.com/seeds/writable-ctes-improve-performance
>

Craig Ringer explained some of the pitfalls of this approach here:

http://dba.stackexchange.com/questions/78510/why-is-cte-open-to-lost-updates

which is a follow up question based on this: http://stackoverflow.com/a/8702291/330315

Thomas



pgsql-general by date:

Previous
From: Brian Dunavant
Date:
Subject: Re: Simple Atomic Relationship Insert
Next
From: Brian Dunavant
Date:
Subject: Re: Simple Atomic Relationship Insert