Re: INSERT OU UPDATE WITHOUT SELECT?

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: PFC <lists(at)peufeu(dot)com>
Cc: "Jonah H(dot) Harris" <jonah(dot)harris(at)gmail(dot)com>, Waldomiro <waldomiro(at)shx(dot)com(dot)br>, pgsql-performance(at)postgresql(dot)org
Subject: Re: INSERT OU UPDATE WITHOUT SELECT?
Date: 2006-05-30 22:38:18
Message-ID: 20060530223818.GK31547@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Dave Dutcher 2006-05-30 22:54:00 Re: INSERT OU UPDATE WITHOUT SELECT?
Previous Message PFC 2006-05-30 22:37:03 Re: Optimizing a huge_table/tiny_table join