Re: Bug in nbtree optimization to skip > operator comparisons (or < comparisons in backwards scans)

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: Bug in nbtree optimization to skip > operator comparisons (or < comparisons in backwards scans)
Дата
Msg-id CAH2-Wz=ZZjYwNGQ-AOQwczyNwbaFNPt7grWTLfxVwKbEEUQmQw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Bug in nbtree optimization to skip > operator comparisons (or < comparisons in backwards scans)  (Matthias van de Meent <boekewurm+postgres@gmail.com>)
Список pgsql-hackers
On Wed, Dec 6, 2023 at 11:14 AM Matthias van de Meent
<boekewurm+postgres@gmail.com> wrote:
> I was thinking more along the lines of page splits+deletions while
> we're doing _bt_stepright(), but forgot to consider that we first lock
> the right sibling, and only then release the left sibling for splits,
> so we should be fine here.

In general the simplest (and possibly most convincing) arguments for
the correctness of optimizations like the ones that Alexander added
rely on seeing that the only way that the optimization can be wrong is
if some more fundamental and long established thing was also wrong. We
could try to prove that the new optimization is correct (or wrong),
but it is often more helpful to "prove" that some much more
fundamental thing is correct instead, if that provides us with a
useful corollary about the new thing also being correct.

Take the _bt_readpage precheck optimization, for example. Rather than
thinking about the key space and transitive rules, it might be more
helpful to focus on what must have been true in earlier Postgres
versions, and what we can expect to still hold now. The only way that
that optimization could be wrong is if the same old _bt_checkkeys
logic that decides when to terminate the scan (by setting
continuescan=false) always had some propensity to "change its mind"
about ending the scan, at least when it somehow got the opportunity to
see tuples after the first tuple that it indicated should end the
scan. That's not quite bulletproof, of course (it's not like older
Postgres versions actually provided _bt_checkkeys with opportunities
to "change its mind" in this sense), but it's a useful starting point
IME. It helps to build intuition.

--
Peter Geoghegan



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Joe Conway
Дата:
Сообщение: Re: Emitting JSON to file using COPY TO
Следующее
От: Peter Eisentraut
Дата:
Сообщение: automating RangeTblEntry node support