Re: Re: new patch of MERGE (merge_204) & a question about duplicated ctid

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Marko Tiikkaja <marko(dot)tiikkaja(at)cs(dot)helsinki(dot)fi>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Boxuan Zhai <bxzhai2010(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org, Stephen Frost <sfrost(at)snowman(dot)net>
Subject: Re: Re: new patch of MERGE (merge_204) & a question about duplicated ctid
Date: 2011-01-04 10:11:59
Message-ID: 4D22F26F.2000603@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Robert Haas wrote:
> And even if it isn't, the MERGE syntax is insane if what you really
> want to do is insert or update ONE record. If all we have is MERGE,
> people will keep doing it with a PL/pgsql stored procedure or some
> crummy application logic just so that they don't have to spend several
> days trying to understand the syntax. Heck, I understand the syntax
> (or I think I do) and I still think it's more trouble than its worth

I hoped that the manual would have a clear example of "this is how you
do UPSERT with MERGE", preferrably cross-linked to the existing "Example
39-2. Exceptions with UPDATE/INSERT" trigger implementation that's been
the reference implementation for this for a long time, so people can see
both alternatives. New users will cut and paste that example into their
code, and in the beginning neither know nor care how MERGE actually
works, so long as the example does what it claims. I would wager the
majority of PL/pgsql implementations of this requirement start the exact
same way. I don't think the learning curve there is really smaller,
it's just that you've just already been through it.

I've been purposefully ignoring the larger applications of MERGE in the
interest of keeping focus on a managable subset. But the more general
feature set is in fact enormously useful for some types of data
warehouse applications. Build REPLACE, and you built REPLACE. Build
MERGE that is REPLACE now and eventually full high-performance MERGE,
and you've done something with a much brighter future. I don't think
the concurrency hurdles here are unique to this feature either, as shown
by the regular overlap noted with the other serialization work.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services and Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christian Ullrich 2011-01-04 10:46:20 Re: SSPI client authentication in non-Windows builds
Previous Message Hannu Krosing 2011-01-04 10:09:10 Re: pg_dump --split patch