Re: ignore unique violation OR check row exists - Mailing list pgsql-sql

From Zdravko Balorda
Subject Re: ignore unique violation OR check row exists
Date
Msg-id 4F044733.6020007@siix.com
Whole thread Raw
In response to Re: ignore unique violation OR check row exists  (Samuel Gendler <sgendler@ideasculptor.com>)
Responses Re: ignore unique violation OR check row exists  (rverghese <riyav@hotmail.com>)
List pgsql-sql
Samuel Gendler wrote:
> 
> 
> On Wed, Jan 4, 2012 at 1:57 AM, Zdravko Balorda 
> <zdravko.balorda@siix.com <mailto:zdravko.balorda@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 should. Ignoring UNIQUE VIOLATION or any other error
>     defeats the very
>     purpose of transaction. That's why you can't ignore it.
> 
> 
> Unfortunately, bulk inserts are much slower when they don't occur in a 
> transaction.  Try inserting 1 million rows with auto commit enabled vs 1 
> million rows in 1 transaction, or even 10 or 100 transactions. The 
> difference is enormous.  The bulk insert into an unconstrained table and 
> then pulling just the new rows over into the destination table in a 
> single transaction is definitely the most effective way to do this.
> 

I do a lot of bulk inserts. What helps is dropping indexes before insert
and recreating it after. Probably you need to better organize data to
avoid having primary keys on a table with a lots of data.

Zdravko



pgsql-sql by date:

Previous
From: Misa Simic
Date:
Subject: Re: ignore unique violation OR check row exists
Next
From: rverghese
Date:
Subject: Re: ignore unique violation OR check row exists