Re: Saving stack space in nbtree's _bt_first function

Mircea Cadariu <cadariu.mircea@gmail.com>

From: Mircea Cadariu <cadariu.mircea@gmail.com>
To: Peter Geoghegan <pg@bowt.ie>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-07-15T20:50:51Z
Lists: pgsql-hackers
Hi,

On 07/07/2025 01:22, Peter Geoghegan wrote:
> However, there's no reason why "ScanKeyData
> notnullkeys[INDEX_MAX_KEYS]" needs to be an array at all. In practice,
> _bt_first will only need a single temp notnullkeys ScanKeyData, since
> there can never be more than a single deduced NOT NULL constraint used
> within our final insertion scan key.

As an experiment, I added an elog(WARNING,...) just above the main 
changed line in the patch, and then ran the tests (make installcheck). 
This resulted in lines logged next to some of the SELECT statements in 
the following files in src/test/regress/sql:

  * create_index.sql
  * inherit.sql

I saw the log line only once per query, showing that at least for the 
scenarios in the tests, the claim checks out. I then tried a couple of 
modifications to those queries which generated the log line, but did not 
get it to log more than once.


Kind regards,

Mircea Cadariu