Re: INSERT ... ON CONFLICT DO UPDATE with _any_ constraint

From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Simon Riggs <simon(at)2ndquadrant(dot)com>, Geoff Winkless <pgsqladmin(at)geoff(dot)dj>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: INSERT ... ON CONFLICT DO UPDATE with _any_ constraint
Date: 2015-05-20 00:12:43
Message-ID: CAM3SWZS2eHo73XepbFcv8RnNFteyZYNjE7S7xZ7-Lw=-va6=8A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 19, 2015 at 5:03 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Peter Geoghegan <pg(at)heroku(dot)com> writes:
>> I think I agree with you, though: We should change things so that the
>> relcache gives indexes in something like the ordering that you
>> outline, rather than in the current arbitrary (though consistent) OID
>> order.
>
> I'm fairly sure that there are aspects of the code that rely on indexes
> being returned by RelationGetIndexList() in a stable order. While I doubt
> that has to be exactly increasing-OID-order, I'm quite concerned about
> allowing the order to depend on mutable aspects of the indexes, like
> names.

I thought the importance of the ordering was just down to some AMs
(like hash) using heavyweight locks. This could cause unprincipled
deadlocks in the face of an inconsistent ordering. nbtree used to use
page-level heavyweight locks many years ago, too, so this used to be a
big, obvious requirement. Maybe there is another reason, but AFAICR
there are no hints of that from the relevant code, and I've looked
carefully.

If it was ever changed, I think it could be done in a way that didn't
add any problems, assuming I've accounted for all the ways in which
changing the ordering could be problematic.
--
Peter Geoghegan

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-05-20 01:05:46 Re: Change pg_cancel_*() to ignore current backend
Previous Message Tom Lane 2015-05-20 00:03:22 Re: INSERT ... ON CONFLICT DO UPDATE with _any_ constraint