Re: Fix size estimation for parallel B-Tree scans with skip arrays - Mailing list pgsql-bugs

From Siddharth Kothari
Subject Re: Fix size estimation for parallel B-Tree scans with skip arrays
Date
Msg-id CAGCUe0L+M113dXmW44LWDmqSHa8kMcwAKgW+hXdTwVd-8dz8jA@mail.gmail.com
Whole thread
In response to Re: Fix size estimation for parallel B-Tree scans with skip arrays  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-bugs
Thank you Peter!

On Wed, Apr 29, 2026 at 8:14 PM Peter Geoghegan <pg@bowt.ie> wrote:
On Wed, Apr 29, 2026 at 2:54 AM Siddharth Kothari <sidkot@google.com> wrote:
> Root cause:
>
> In src/backend/access/nbtree/nbtree.c, the loop in btestimateparallelscan assumes that every index column might require a skip array and adds sizeof(int) to the estimated size:
>
> However, every skip array actually needs space for its slot in the btps_arrElems array AND space to store its scan key's sk_flags.

Your diagnosis looks correct to me. As you said, the problem is that
we only add btps_arrElems space overhead for input scan keys -- we
neglect to do the same for any skip array scan key that might be
output by nbtree preprocessing later on.

I'll commit this patch later today.

Thanks!
--
Peter Geoghegan

pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Fix size estimation for parallel B-Tree scans with skip arrays
Next
From: Tomas Vondra
Date:
Subject: Re: Fix size estimation for parallel B-Tree scans with skip arrays