Re: Using indexUnchanged with nbtree

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Using indexUnchanged with nbtree
Date: 2021-06-23 16:42:21
Message-ID: CAH2-WznHigE3XVW-cq=O0GLpV=wZZVJimvZgd581pWV9rQuQ1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jun 23, 2021 at 9:31 AM Simon Riggs
<simon(dot)riggs(at)enterprisedb(dot)com> wrote:
> You're right that skipping the check might also skip killing a prior
> row version, but it doesn't prevent later scans from killing them, so
> there is no correctness aspect to that.

Probably not, no. I'll assume for now that there is no correctness issue.

> In the case of a non-HOT UPDATE the backend will see the index entry
> for the old row version and then check it, pointlessly. Since that has
> just been modified, that won't ever be killed, so skipping the check
> makes sense in those cases.

I agree that the check itself is pointless here. But that in itself
doesn't make the call to _bt_check_unique() useless. It might still
manage to set LP_DEAD bits when nothing else will.

I realize that the original reason for setting LP_DEAD bits in
_bt_check_unique() was something like "well, might as well do this
here too". But I believe that LP_DEAD bit setting inside
_bt_check_unique() is nevertheless often more valuable than the better
known kill_prior_tuple mechanism. I have seen clear and convincing
examples of this in the past. Might not really be true anymore.

Another thing is _bt_findinsertloc() and
_bt_delete_or_dedup_one_page(), which themselves use the
checkingunique flag that you're changing the value of. There could
also be unintended side-effects there. OTOH they also use
indexUnchanged too, so even if there is a problem it might be fixable.

--
Peter Geoghegan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2021-06-23 16:55:40 Re: Pipeline mode and PQpipelineSync()
Previous Message Simon Riggs 2021-06-23 16:31:02 Re: Using indexUnchanged with nbtree