Re: btree: downlink right separator/HIKEY optimization - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: btree: downlink right separator/HIKEY optimization
Date
Msg-id CAH2-WzkooESsOa8DKXkuYR-wuj2hcvcN5VrCCkNzSuXwM6WDFA@mail.gmail.com
Whole thread Raw
In response to Re: btree: downlink right separator/HIKEY optimization  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Responses Re: btree: downlink right separator/HIKEY optimization
Re: btree: downlink right separator/HIKEY optimization
List pgsql-hackers
On Thu, Feb 22, 2024 at 10:42 AM Matthias van de Meent
<boekewurm+postgres@gmail.com> wrote:
> I forgot to address this in the previous patch, so here's v3 which
> fixes the issue warning.

What benchmarking have you done here?

Have you tried just reordering things in _bt_search() instead? If we
delay the check until after the binary search, then the result of the
binary search is usually proof enough that we cannot possibly need to
move right. That has the advantage of not requiring that we copy
anything to the stack.

Admittedly, it's harder to make the "binary search first" approach
work on the leaf level, under the current code structure. But maybe
that doesn't matter very much. And even if it does matter, maybe we
should just move the call to _bt_binsrch() that currently takes place
in _bt_first into _bt_search() itself -- so that _bt_binsrch() is
strictly under the control of _bt_search() (obviously not doable for
non-_bt_first callers, which need to call _bt_binsrch_insert instead).
This whole approach will have been made easier by the refactoring I
did late last year, in commit c9c0589fda.

--
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: pipe_read_line for reading arbitrary strings
Next
From: Corey Huinker
Date:
Subject: Re: Statistics Import and Export