Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification)

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification)
Date: 2016-03-16 16:09:16
Message-ID: CA+TgmoY-NzNMzWZk1PFOjLFPz8bJM8Xx2Eh_W0Au7B25K-19pQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Mar 16, 2016 at 3:09 AM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
wrote:

> On Wed, Mar 9, 2016 at 11:58 PM, Robert Haas <robertmhaas(at)gmail(dot)com>
> wrote:
> >
> > On Wed, Mar 9, 2016 at 12:33 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > >
> > > Gather is a bit weird, because although it can project (and needs to,
> > > per the example of needing to compute a non-parallel-safe function),
> > > you would rather push down as much work as possible to the child node;
> > > and doing so is semantically OK for parallel-safe functions. (Pushing
> > > functions down past a Sort node, for a counterexample, is not so OK
> > > if you are concerned about function evaluation order, or even number
> > > of executions.)
> > >
> > > In the current code structure it would perhaps be reasonable to teach
> > > apply_projection_to_path about that --- although this would require
> > > logic to separate parallel-safe and non-parallel-safe subexpressions,
> > > which doesn't quite seem like something apply_projection_to_path
> > > should be doing.
> >
> > I think for v1 it would be fine to make this all-or-nothing; that's
> > what I had in mind to do. That is, if the entire tlist is
> > parallel-safe, push it all down. If not, let the workers just return
> > the necessary Vars and have Gather compute the final tlist.
> >
>
> I find it quite convenient to teach apply_projection_to_path() to push
> down target-list beneath Gather node, when targetlist contains
> parallel-safe expression. Attached patch implements pushing targetlist
> beneath gather node.
>

That doesn't update the cost of the subpath, which it probably needs to
do. I wonder if this shouldn't be implemented by recursing.

if (IsA(path, GatherPath) && !has_parallel_hazard((Node *) target->exprs,
false))
apply_projection_to_path(root, something, ((GatherPath *)
path)->subpath, target);

Tom, any comments? I think it would be smart to push this into 9.6.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2016-03-16 16:09:54 Re: [PATH] Jsonb, insert a new value into an array at arbitrary position
Previous Message David Steele 2016-03-16 16:06:39 Re: Updated backup APIs for non-exclusive backups