Re: someone working to add merge?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org, Josh Berkus <josh(at)agliodbs(dot)com>, Jaime Casanova <systemguards(at)gmail(dot)com>
Subject: Re: someone working to add merge?
Date: 2005-11-11 19:22:46
Message-ID: 20051111192246.GA1206@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Nov 11, 2005 at 18:48:33 +0100,
Csaba Nagy <nagy(at)ecircle-ag(dot)com> wrote:
> OK, I'm relatively new on this list, and I might have missed a few
> discussions on this topic.
> I wonder if doing it this way would not be better than using a table
> lock:
>
> - set a save point;
> - insert the row;
> - on error:
> - roll back to the save point;
> - update the row;
> - on success release the save point;
>
> This would provide less contention while paying the prise for the save
> point. In low contention scenarios the table lock would be better, and I
> wonder for high contention scenarios which is better, the table lock, or
> the save point version...

You may not be able to update the row after the insert fails. If there is
insert occurring in another transaction, the row may not be visible to
the current transaction. In which case you can neither insert or update the
row. You need to wait for the other transaction to commit or rollback.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2005-11-11 20:01:55 MERGE vs REPLACE
Previous Message Tom Lane 2005-11-11 19:20:41 Re: someone working to add merge?