Hi Hackers,

While reviewing the code, I found the original comment difficult to follow, so I am trying to rephrase it for clarity.

Regards,

Chao Li (Evan)

--------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
From d4bfb58e2904c919f0891643142fc87069a2c69d Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <l...@highgo.com>
Date: Fri, 15 Aug 2025 16:28:21 +0800
Subject: [PATCH v1] Clarify comment in _bt_set_startikey

While reviewing the code, I found the original comment difficult to follow,
so I rephrased it for clarity.

Author: Li Chao <l...@highgo.com>
---
 src/backend/access/nbtree/nbtutils.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/nbtree/nbtutils.c 
b/src/backend/access/nbtree/nbtutils.c
index 9aed207995f..83bb4b80491 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -2432,9 +2432,12 @@ _bt_set_startikey(IndexScanDesc scan, BTReadPageState 
*pstate)
                int32           result;
 
                /*
-                * Determine if it's safe to set pstate.startikey to an offset 
to a
-                * key that comes after this key, by examining this key
-                */
+               * Determine whether we can set pstate.startikey to a later key 
offset,
+               * ensuring that all earlier scan keys are satisfied by every 
tuple on
+               * the current page. This is done by comparing the key against 
the first
+               * and last tuples on the page.
+               */
+
                if (!(key->sk_flags & (SK_BT_REQFWD | SK_BT_REQBKWD)))
                {
                        /* Scan key isn't marked required (corner case) */
-- 
2.39.5 (Apple Git-154)

Reply via email to