Re: Returning nbtree posting list TIDs in DESC order during backwards scans

From: Victor Yegorov <vyegorov(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: Returning nbtree posting list TIDs in DESC order during backwards scans
Date: 2025-12-10 19:41:13
Message-ID: CAGnEboirgArezZDNeFrR8FOGvKF-Xok333s2iVwWi65gZf8MEA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

ср, 10 дек. 2025 г. в 21:40, Peter Geoghegan <pg(at)bowt(dot)ie>:

> Attached v5 avoids the regression by tweaking _bt_readpage. I will
> commit this version soon (I really mean it this time!).
>
> …
>
> I also gave up on the idea of using a bitmapset for v5 -- the issue
> with regressing _bt_readpage discouraged me from adding code that
> allocates memory (more than once per scan) within btgettuple, which is
> a performance-critical path. We can simply sort and unique-ify the
> killedItems array from within _bt_killitems instead -- which is
> largely the same way that my original v1 did it. That way it won't
> matter what order we append to killItems in, relative to the scan
> direction. (The downside of sticking with an array for killedItems is
> that we can still run out of array space in extreme cases involving
> scrollable cursors that return many killable tuples, and repeatedly
> append the same TID to killedItems[], but that doesn't seem like much
> of a loss to me -- that almost never happens in practice.)
>

Compiled and tested without issues.

Small note: as you're removing “We rely on the convention that heap TIDs in
the scanpos
items array are stored in ascending heap TID order…” part of the comment,
perhaps it'd be
good to add smth similar to that to the “Sort and uniqueify
so->killedItems[] to deal with all this.”
piece? Smth like:

+ * Sort and uniqueify so->killedItems[] to deal with all this,
+ * as TIDs are processed in ascending order.

I feel the need for such a comment from my POV as a code reader.

--
Victor Yegorov

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jacob Champion 2025-12-10 20:02:23 Re: Periodic authorization expiration checks using GoAway message
Previous Message Tom Lane 2025-12-10 19:32:37 Re: Solaris versus our NLS files