Teach create_projection_plan to omit projection where possible.
authorRobert Haas <rhaas@postgresql.org>
Thu, 29 Mar 2018 19:37:39 +0000 (15:37 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 29 Mar 2018 19:37:48 +0000 (15:37 -0400)
commitd7c19e62a8e0a634eb6b29f8f1111d944e57081f
treed5dda92d09f3c128302bab210fdf08ff503eade0
parent20b4323bd107920a3c3e60452442e8e2cee302d2
Teach create_projection_plan to omit projection where possible.

We sometimes insert a ProjectionPath into a plan tree when projection
is not strictly required. The existing code already arranges to avoid
emitting a Result node when the ProjectionPath's subpath can perform
the projection itself, but previously it didn't consider the
possibility that the parent node might not actually require the
projection to be performed at all.

Skipping projection when it's not required can not only avoid Result
nodes that aren't needed, but also avoid losing the "physical tlist"
optimization unneccessarily.

Patch by me, reviewed by Amit Kapila.

Discussion: http://postgr.es/m/CA+TgmoakT5gmahbPWGqrR2nAdFOMAOnOXYoWHRdVfGWs34t6_A@mail.gmail.com
src/backend/optimizer/plan/createplan.c