Re: Avoiding superfluous buffer locking during nbtree backwards scans

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Avoiding superfluous buffer locking during nbtree backwards scans
Date: 2024-09-02 11:31:55
Message-ID: CAEze2WiQo_ZaoO5QHOxRTXdFZxnKpjtDC=2MpS2AMSxh8Kbi3A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 30 Aug 2024 at 21:43, Matthias van de Meent
<boekewurm+postgres(at)gmail(dot)com> wrote:
>
> On Mon, 19 Aug 2024 at 13:43, Matthias van de Meent
> <boekewurm+postgres(at)gmail(dot)com> wrote:
> >
> > On Sun, 11 Aug 2024 at 21:44, Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> > >
> > > On Tue, Aug 6, 2024 at 6:31 PM Matthias van de Meent
> > > <boekewurm+postgres(at)gmail(dot)com> wrote:
> > > > +1, LGTM.
> > > >
> > > > This changes the backward scan code in _bt_readpage to have an
> > > > approximately equivalent handling as the forward scan case for
> > > > end-of-scan cases, which is an improvement IMO.
> >
> > Here's a new patch that further improves the situation, so that we
> > don't try to re-lock the buffer we just accessed when we're stepping
> > backward in index scans, reducing buffer lock operations in the common
> > case by 1/2.
>
> Attached is an updated version of the patch, now v2, which fixes some
> assertion failures for parallel plans by passing the correct
> parameters to _bt_parallel_release for forward scans.

I noticed I attached an older version of the patch which still had 1
assertion failure case remaining (thanks cfbot), so here's v3 which
solves that problem.

Kind regards,

Matthias van de Meent
Neon (https://neon.tech)

Attachment Content-Type Size
v3-0001-Avoid-unneeded-nbtree-backwards-scan-buffer-locks.patch application/octet-stream 18.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2024-09-02 11:38:06 Re: Jargon and acronyms on this mailing list
Previous Message Dagfinn Ilmari Mannsåker 2024-09-02 11:06:18 Re: Jargon and acronyms on this mailing list