Re: ignore unique violation OR check row exists

From: Misa Simic <misa(dot)simic(at)gmail(dot)com>
To: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: ignore unique violation OR check row exists
Date: 2012-01-04 10:23:29
Message-ID: 4121874819344867495@unknownmsgid
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Well, idea is to make process faster as possible... And usualy staging
table does not have any constrains so can't violates...

When we want to import banch of data... Process when we taking row by
row from source, validate it, if valid insert to some table could be
very slow...

Much faster is when we work with sets..

•import all records to some table without constrains (staging table).
And best would be if we can use COPY command instead of insert...

•inert into liveTable select all valid records from stagingTable

Of course it is just in case when we want to import what is ok... In
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(at)postgresql(dot)org
Subject: Re: [SQL] ignore unique violation OR check row exists
On 2012-01-03, Misa Simic <misa(dot)simic(at)gmail(dot)com> 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 exist in
> live...
>

Its a good idea to check that the staging table doesn't
conflict with itself, before tryign to insert it.

--
⚂⚃ 100% natural

Browse pgsql-sql by date

  From Date Subject
Next Message Zdravko Balorda 2012-01-04 12:33:55 Re: ignore unique violation OR check row exists
Previous Message Samuel Gendler 2012-01-04 10:09:54 Re: ignore unique violation OR check row exists