pgsql: nbtree: Use only one notnullkey ScanKeyData.

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: nbtree: Use only one notnullkey ScanKeyData.
Date: 2025-07-16 17:06:30
Message-ID: E1uc5aQ-006cJr-2R@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

nbtree: Use only one notnullkey ScanKeyData.

_bt_first need only store one ScanKeyData struct on the stack for the
purposes of building an IS NOT NULL key based on an implied NOT NULL
constraint. We don't need INDEX_MAX_KEYS-many ScanKeyData structs.

This saves us a little over 2KB in stack space. It's possible that this
has some performance benefit. It also seems simpler and more direct.

It isn't possible for more than a single index attribute to need its own
implied IS NOT NULL key: the first such attribute/IS NOT NULL key always
makes _bt_first stop adding additional boundary keys to startKeys[].
Using INDEX_MAX_KEYS-many ScanKeyData entries was (at best) misleading.

Author: Peter Geoghegan <pg(at)bowt(dot)ie>
Reviewed-By: Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>
Discussion: https://postgr.es/m/CAH2-Wzm=1kJMSZhhTLoM5BPbwQNWxUj-ynOEh=89ptDZAVgauw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4c8ad67a98b5d84c1ca00a26d53d08f2d2b881aa

Modified Files
--------------
src/backend/access/nbtree/nbtsearch.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Álvaro Herrera 2025-07-16 17:23:59 pgsql: Fix dumping of comments on invalid constraints on domains
Previous Message Jeff Davis 2025-07-16 17:01:51 pgsql: pg_dumpall: Skip global objects with --statistics-only or --no-s