pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Misa Simic <misa.simic@gmail.com>
To: Jasen Betts <jasen@xnet.co.nz>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: ignore unique violation OR check row exists
Date: Wed, 4 Jan 2012 02:23:29 -0800
Message-ID: <4121874819344867495@unknownmsgid> (raw)

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@postgresql.org
Subject: Re: [SQL] ignore unique violation OR check row exists
On 2012-01-03, Misa Simic <misa.simic@gmail.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


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (9+ messages)  latest in thread

Message-ID: <4121874819344867495@unknownmsgid>
Permalink:  ../4121874819344867495@unknownmsgid/
Also on:    postgresql.org/message-id/4121874819344867495@unknownmsgid

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: misa.simic@gmail.com, jasen@xnet.co.nz
  Subject: Re: ignore unique violation OR check row exists
  In-Reply-To: <4121874819344867495@unknownmsgid>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox