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

Victor Yegorov <vyegorov@gmail.com>

From: Victor Yegorov <vyegorov@gmail.com>
To: Peter Geoghegan <pg@bowt.ie>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-03T15:18:30Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Clarify why _bt_killitems sorts its items array.

  2. Return TIDs in desc order during backwards scans.

  3. Optimize nbtree backwards scans.

  4. Optimize nbtree backward scan boundary cases.

ср, 3 дек. 2025 г. в 06:09, Peter Geoghegan <pg@bowt.ie>:

> Coming back to this patch now, after several months of work on index
> prefetching.
>
> I decided that it wasn't such a great idea to reuse/steal an unused
> "itemDead" bit from the BTScanPosItem.itemOffset field after all. That
> forces _bt_killitems to iterate through every so->currPos.item[], not
> just those that are known to require LP_DEAD marking.
>
> Tomas Vondra suggested that I keep killedItems as a separate
> allocation (as it is on master), while using a Bitmapset to represent
> killedItems (unlike on master, where it is represented using a simple
> array). This has all of the same advantages as my previous approach,
> but doesn't have the aforementioned disadvantages within _bt_killitems
> (plus we no longer need to change BTScanPosItem in any way).
>
> Attached is v4, which does it that way.
>
> My plan is to commit this improved version in the next couple of days.
>
> --
> Peter Geoghegan
>

Patch looks fine, applies and compiles cleanly, passes tests.

I'd like to point out a missing space after the dot in the 2nd para of the
commit message,
falls out of style.

-- 
Victor Yegorov