Re: Returning nbtree posting list TIDs in DESC order during backwards scans
Peter Geoghegan <pg@bowt.ie>
From: Peter Geoghegan <pg@bowt.ie>
To: Mircea Cadariu <cadariu.mircea@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-17T19:37:31Z
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 →
-
Clarify why _bt_killitems sorts its items array.
- e16c6f024718 19 (unreleased) landed
-
Return TIDs in desc order during backwards scans.
- bfb335df58ea 19 (unreleased) landed
-
Optimize nbtree backwards scans.
- 1bd4bc85cac2 18.0 cited
-
Optimize nbtree backward scan boundary cases.
- c9c0589fda0e 17.0 cited
Attachments
- v3-0001-Return-TIDs-in-desc-order-during-backwards-scans.patch (application/octet-stream) patch v3-0001
On Thu, Jul 17, 2025 at 2:26 PM Peter Geoghegan <pg@bowt.ie> wrote: > The loop has an early check for this (for non-itemDead entries) here: > > /* Quickly skip over items never ItemDead-set by btgettuple */ > if (!kitem->itemDead) > continue; > > I really doubt that this matters I think that this patch isn't too far off being committable. I'll need to think about issues around adding the new kitem->itemDead bitfield. I'm not really worried about _bt_killitems; more so about the routines called by _bt_readpage, which must make sure that the bit is unset every time a TID is saved in so->currPos.items[]. Attached is v3. Not much has changed. We now defensively unset each previously set kitem->itemDead within _bt_killitems. I've also added a pair of macros that represent 0 and 1 values for these kitem->itemDead bits. Thanks -- Peter Geoghegan