Re: someone working to add merge? - Mailing list pgsql-hackers

From Bruno Wolff III
Subject Re: someone working to add merge?
Date
Msg-id 20051111192246.GA1206@wolff.to
Whole thread Raw
In response to Re: someone working to add merge?  (Csaba Nagy <nagy@ecircle-ag.com>)
Responses Re: someone working to add merge?  (Csaba Nagy <nagy@ecircle-ag.com>)
List pgsql-hackers
On Fri, Nov 11, 2005 at 18:48:33 +0100, Csaba Nagy <nagy@ecircle-ag.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.


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Multi-table-unique-constraint
Next
From: Tom Lane
Date:
Subject: Re: someone working to add merge?