Re: BUG #19372: Scan operator maybe output unnecessary columns to the upper-layer operators

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: yaojia_0809(at)163(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19372: Scan operator maybe output unnecessary columns to the upper-layer operators
Date: 2026-01-07 09:25:37
Message-ID: CAApHDvqaxvdvwe1ZZrTjRZsrkpzEtKq8QyPAmLH24rCP887ToQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 7 Jan 2026 at 21:49, PG Bug reporting form
<noreply(at)postgresql(dot)org> wrote:
> The scan operator maybe output unnecessary columns to the upper-layer
> operators. This seems like redundant work because the upper-layer operators
> don't need these column data at all. This undoubtedly increases execution
> overhead.
> Is this behavior intentionally designed this way, or is it an unintended
> side effect? Should the unnecessary column output be eliminated?

It's working as intended. This is useful for HeapAm as TupleTableSlots
can carry a pointer to the tuple on the page and deform only up to the
last column that's required. If you want the Seq Scan to only have
the columns required at the scan level, then that requires a
projection operation at the scan level. In your query, only columns 1
and 2 will be deformed from the tuple and that'll happen during the
HashAggregate. No tuple deformation is required before that in your
query.

Where this behaviour isn't ideal is for table AMs such as column
stores. Ideally, we'd leave this up to the table AM to state if it's
useful or not, but we currently don't have that ability. I'm surprised
nobody has asked for that yet.

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Amit Langote 2026-01-07 09:37:12 Re: BUG #19355: Attempt to insert data unexpectedly during concurrent update
Previous Message PG Bug reporting form 2026-01-07 08:11:02 BUG #19372: Scan operator maybe output unnecessary columns to the upper-layer operators