Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification) - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification)
Date
Msg-id CAA4eK1JkU-Y+tBOZP-zngJgKVMkbytYSMsAEu7-yxR86JM+CYw@mail.gmail.com
Whole thread Raw
In response to Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification)  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Pushdown target list below gather node (WAS Re: WIP: Upper planner pathification)
List pgsql-hackers
On Wed, Mar 16, 2016 at 10:57 PM, Robert Haas <robertmhaas@gmail.com> wrote:
>
> On Wed, Mar 16, 2016 at 12:57 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Yeah, I was thinking about the same thing.  The comment block above
> > where you're looking would need some adjustment.
>
> OK, how about this?
>

+ * children.  Alternatively, apply_projection_to_path might have created

+ * a projection path as the subpath of a Gather node even though the

+ * subpath was projection-capable.  So, if the subpath is capable of

+ * projection or the desired tlist is the same expression-wise as the

+ * subplan's, just jam it in there.  We'll have charged for a Result that

+ * doesn't actually appear in the plan, but that's better than having a

+ * Result we don't need.

  */

- if (tlist_same_exprs(tlist, subplan->targetlist))

+ if (is_projection_capable_path(best_path->subpath) ||

+ tlist_same_exprs(tlist, subplan->targetlist))




While reading above code changes, it looks like it is assuming that subpath and subplan will always be same (as it is verifying projection capability of subpath and attaching the tlist to subplan), but I think it is possible that subpath and subplan correspond to different nodes when gating Result node is added on to top of scan plan by create_scan_plan().  I think it might be better to explain in comments, why it is safe to rely on projection capability of subpath to attach tlist to subplan.


With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com

pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: IF (NOT) EXISTS in psql-completion
Next
From: Oskari Saarenmaa
Date:
Subject: Re: Show dropped users' backends in pg_stat_activity