Re: make Gather node projection-capable

From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: make Gather node projection-capable
Date: 2015-10-25 15:59:55
Message-ID: CANP8+jKdq-n0+epbfH6_429tnt9FGG_sxZ5D9mDeYwLGTKUoUQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22 October 2015 at 16:01, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> If we make Gather projection-capable,
> we can just end up with Gather->PartialSeqScan.
>

Is there a reason not to do projection in the Gather node? I don't see one.

> > That said, I don't understand Tom's comment either. Surely the planner
> > is going to choose to do the projection in the innermost node possible,
> > so that the children nodes are going to do the projections most of the
> > time. But if for whatever reason this fails to happen, wouldn't it make
> > more sense to do it at Gather than having to put a Result on top?
>
> The planner doesn't seem to choose to do projection in the innermost
> node possible. The final tlist only gets projected at the top of the
> join tree. Beneath that, it seems like we project in order to avoid
> carrying Vars through nodes where that would be a needless expense,
> but that's just dropping columns, not computing anything. That having
> been said, I don't think that takes anything away from your chain of
> reasoning here, and I agree with your conclusion. There seems to be
> little reason to force a Result node atop a Gather node when we don't
> do that for most other node types.
>

Presumably this is a performance issue then? If we are calculating
something *after* a join which increases rows then the query will be slower
than need be.

I agree the rule should be to project as early as possible.

--
Simon Riggs http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2015-10-25 18:12:27 pgbench gaussian/exponential docs improvements
Previous Message David Fetter 2015-10-25 15:21:18 Re: Proposal: Trigonometric functions in degrees