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 298A89FA5E1 for ; Tue, 30 May 2006 19:38:25 -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 25230-06 for ; Tue, 30 May 2006 19:38:20 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from alvh.no-ip.org (201-221-200-231.bk11-dsl.surnet.cl [201.221.200.231]) by postgresql.org (Postfix) with ESMTP id 145679FA5E9 for ; Tue, 30 May 2006 19:38:20 -0300 (ADT) Received: by alvh.no-ip.org (Postfix, from userid 1000) id 6D650C3A214; Tue, 30 May 2006 18:38:18 -0400 (CLT) Date: Tue, 30 May 2006 18:38:18 -0400 From: Alvaro Herrera To: PFC Cc: "Jonah H. Harris" , Waldomiro , pgsql-performance@postgresql.org Subject: Re: INSERT OU UPDATE WITHOUT SELECT? Message-ID: <20060530223818.GK31547@surnet.cl> Mail-Followup-To: PFC , "Jonah H. Harris" , Waldomiro , pgsql-performance@postgresql.org References: <447C8F1D.8090404@shx.com.br> <36e682920605301405u4d665fcftbe0a97b5753f5209@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.11+cvs20060403 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/555 X-Sequence-Number: 19342 PFC wrote: > >PostgreSQL does not support MERGE at the moment, sorry. > > Issue an UPDATE, and watch the rowcount ; if the rowcount is 0, > issue an INSERT. > Be prepared to retry if another transaction has inserted the row > meanwhile, though. Oh, you mean, like the example that's in the documentation? http://www.postgresql.org/docs/8.1/static/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING Example 36-1 > MERGE would be really useful. It has been discussed before -- MERGE is something different. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support