X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 644399FA5E9 for ; Tue, 30 May 2006 22:09:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 40053-10 for ; Tue, 30 May 2006 22:09:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from noel.decibel.org (noel.decibel.org [67.100.216.10]) by postgresql.org (Postfix) with ESMTP id A67D59FA5E1 for ; Tue, 30 May 2006 22:09:25 -0300 (ADT) Received: by noel.decibel.org (Postfix, from userid 1001) id A1D9656423; Tue, 30 May 2006 20:09:23 -0500 (CDT) Received: (hashcash-sendmail, from uid 1001); Tue, 30 May 2006 20:09:23 -0500 Date: Tue, 30 May 2006 20:09:22 -0500 From: "Jim C. Nasby" To: Worky Workerson Cc: pgsql-performance@postgresql.org Subject: Re: Bulk loading/merging Message-ID: <20060531010922.GC59464@pervasive.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: FreeBSD 6.0-RELEASE-p4 amd64 X-Distributed: Join the Effort! http://www.distributed.net User-Agent: Mutt/1.5.11 X-Hashcash: 1:20:060531:worky.workerson@gmail.com::uxyLlipPEik9oPuX:000000000000 0000000000000000000000004CX1 X-Hashcash: 1:20:060531:pgsql-performance@postgresql.org::zSTal/Z4dB6eMjsS:00000 0000000000000000000000001fqE X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/559 X-Sequence-Number: 19346 Your best bet is to do this as a single, bulk operation if possible. That way you can simply do an UPDATE ... WHERE EXISTS followed by an INSERT ... SELECT ... WHERE NOT EXISTS. On Fri, May 26, 2006 at 02:48:20PM -0400, Worky Workerson wrote: > I've set up something similar the 'recommended' way to merge data into > the DB, i.e. > > http://www.postgresql.org/docs/current/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING > > however I did it with a trigger on insert, i.e. (not my schema :) ): -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461