Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread rverghese
Thanks for the recommendations. Unfortunately I have to clean out the data before I insert, so I cannot do a bulk copy from a CSV, I will try the option of inserting into src table and then copying relevant data to dest table and see if that works faster for me. I suppose I could bulk insert and th

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Zdravko Balorda
Samuel Gendler wrote: On Wed, Jan 4, 2012 at 1:57 AM, Zdravko Balorda mailto:zdravko.balo...@siix.com>> wrote: Take it out of transaction. Why is there a transaction in the first place? If transaction is needed, ok, but take these inserts out and everything will work as it

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Misa Simic
case all or nothing - import direct to liveTable works fine... Sent from my Windows Phone From: Jasen Betts Sent: 04/01/2012 10:02 To: pgsql-sql@postgresql.org Subject: Re: [SQL] ignore unique violation OR check row exists On 2012-01-03, Misa Simic wrote: > If exists is better, though insert

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Samuel Gendler
On Wed, Jan 4, 2012 at 1:57 AM, Zdravko Balorda wrote: > Andreas Kretschmer wrote: > >> rverghese wrote: >> >> I want to insert a bunch of records and not do anything if the record >>> already >>> exists. So the 2 options I considered are 1) check if row exists or >>> insert >>> and 2) ignore th

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Zdravko Balorda
Andreas Kretschmer wrote: rverghese wrote: I want to insert a bunch of records and not do anything if the record already exists. So the 2 options I considered are 1) check if row exists or insert and 2) ignore the unique violation on insert if row exists. Any opinions on whether it is faster

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Andreas Kretschmer
rverghese wrote: > I want to insert a bunch of records and not do anything if the record already > exists. So the 2 options I considered are 1) check if row exists or insert > and 2) ignore the unique violation on insert if row exists. > Any opinions on whether it is faster to INSERT and then ca

Re: [SQL] ignore unique violation OR check row exists

2012-01-04 Thread Jasen Betts
On 2012-01-03, Misa Simic wrote: > If exists is better, though insert line by line and check if exists may > be very slow... > > The best would be if you can use copy command from csv to staging table > (without constraints) and then > > Insert to live from stage where stage constraint column not

Re: [SQL] ignore unique violation OR check row exists

2012-01-03 Thread Misa Simic
from my Windows Phone From: rverghese Sent: 03/01/2012 21:55 To: pgsql-sql@postgresql.org Subject: [SQL] ignore unique violation OR check row exists I want to insert a bunch of records and not do anything if the record already exists. So the 2 options I considered are 1) check if row exists or insert

[SQL] ignore unique violation OR check row exists

2012-01-03 Thread rverghese
I want to insert a bunch of records and not do anything if the record already exists. So the 2 options I considered are 1) check if row exists or insert and 2) ignore the unique violation on insert if row exists. Any opinions on whether it is faster to INSERT and then catch the UNIQUE VIOLATION ex