Re: Fix size estimation for parallel B-Tree scans with skip arrays

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Siddharth Kothari <sidkot(at)google(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, Vaibhav Jain <jainva(at)google(dot)com>, Madhukar <madhukarprasad(at)google(dot)com>, Xun Cheng <xuncheng(at)google(dot)com>
Subject: Re: Fix size estimation for parallel B-Tree scans with skip arrays
Date: 2026-04-29 14:43:47
Message-ID: CAH2-Wzk6-mzP4utr9=sKT9XQi+NgonD_X30z1sf_hgnKQvPpGg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Apr 29, 2026 at 2:54 AM Siddharth Kothari <sidkot(at)google(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Siddharth Kothari 2026-04-29 14:59:23 Re: Fix size estimation for parallel B-Tree scans with skip arrays
Previous Message Gary Clarke 2026-04-29 12:00:28 Interval unit format bug