Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id A44B02D4D06 for ; Wed, 4 Jan 2012 06:23:46 -0400 (AST) Received: from mail-iy0-f174.google.com ([209.85.210.174]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RiO0V-0008UY-9M for pgsql-sql@postgresql.org; Wed, 04 Jan 2012 10:23:47 +0000 Received: by iaeh11 with SMTP id h11so32353861iae.19 for ; Wed, 04 Jan 2012 02:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=VscMdtAn4Q7cKSwnJhDQwRSPt9/YGOd5Cg7X2fzoF6A=; b=fW6txSmONkjZnGrcliBiwuEW/Zs6PC7k8KZ6GDh6DpGSydkfz+15K33ZhXPJ66GD4h Kk/jaV9+i3G0lgpn/TSgw18V1kYLToWLm3K2m1ps+MtHHbyAlfBUO+219JeqCVZSpoHV 9ewxZ0vyfZs4ZBBkNaUF9We5rTrxxR2csnMK0= Received: by 10.42.72.135 with SMTP id o7mr58541136icj.45.1325672609111; Wed, 04 Jan 2012 02:23:29 -0800 (PST) MIME-Version: 1.0 From: Misa Simic Date: Wed, 4 Jan 2012 02:23:29 -0800 Message-ID: <4121874819344867495@unknownmsgid> Subject: Re: ignore unique violation OR check row exists To: Jasen Betts , "pgsql-sql@postgresql.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201201/17 X-Sequence-Number: 36188 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.. =E2=80=A2import all records to some table without constrains (staging table= ). And best would be if we can use COPY command instead of insert... =E2=80=A2inert 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 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. --=20 =E2=9A=82=E2=9A=83 100% natural --=20 Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql