Re: Returning nbtree posting list TIDs in DESC order during backwards scans - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: Returning nbtree posting list TIDs in DESC order during backwards scans
Date
Msg-id CAH2-Wz=YYoxSpUrPT+cofJQSAd=xEtBTTQX6FCxBhQSvbF-OhA@mail.gmail.com
Whole thread Raw
In response to Re: Returning nbtree posting list TIDs in DESC order during backwards scans  (Andy Fan <zhihuifan1213@163.com>)
Responses Re: Returning nbtree posting list TIDs in DESC order during backwards scans
Re: Returning nbtree posting list TIDs in DESC order during backwards scans
Re: Returning nbtree posting list TIDs in DESC order during backwards scans
List pgsql-hackers
On Sun, Jul 27, 2025 at 9:43 AM Andy Fan <zhihuifan1213@163.com> wrote:
> At last, I can get the same test result as you. The buffer hits go back to
> 23 in the test case, thank for working on this!
>
> > I think that this patch isn't too far off being committable.
>
> I think so.

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

Attachment

pgsql-hackers by date:

Previous
From: Chao Li
Date:
Subject: Re: Cleanup shadows variable warnings, round 1
Next
From: Ajin Cherian
Date:
Subject: Re: Improve pg_sync_replication_slots() to wait for primary to advance