Thread: [HACKERS] Unused field of ProjectionPath

[HACKERS] Unused field of ProjectionPath

From
Antonin Houska
Date:
I've noticed that the dummypp field of ProjectionPath is set but never read.

If the only possible change between the path and plan creation time is that
the projection path and the subpath targetlists become different, then dummypp
could be used this way:

diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c
new file mode 100644
index 5c934f2..1910d3f
*** a/src/backend/optimizer/plan/createplan.c
--- b/src/backend/optimizer/plan/createplan.c
*************** create_projection_plan(PlannerInfo *root
*** 1572,1578 ****        * not using.)        */       if (is_projection_capable_path(best_path->subpath) ||
!               tlist_same_exprs(tlist, subplan->targetlist))       {               /* Don't need a separate Result,
justassign tlist to subplan */               plan = subplan; 
--- 1572,1578 ----        * not using.)        */       if (is_projection_capable_path(best_path->subpath) ||
!               (best_path->dummypp && tlist_same_exprs(tlist, subplan->targetlist)))       {               /* Don't
needa separate Result, just assign tlist to subplan */               plan = subplan; 


On the other hand, if the targetlists can also be different at path creation
time and equal at plan creation time, the lists do always need comparison at
plan creation time and the dummypp field should probably be removed.


--
Antonin Houska
Cybertec Schönig & Schönig GmbH
Gröhrmühlgasse 26
A-2700 Wiener Neustadt
Web: http://www.postgresql-support.de, http://www.cybertec.at



Re: [HACKERS] Unused field of ProjectionPath

From
Tom Lane
Date:
Antonin Houska <ah@cybertec.at> writes:
> I've noticed that the dummypp field of ProjectionPath is set but never read.

I do not think removing that field is a good idea, even if it's not used
in the current form of the logic.  It's useful for debugging purposes at
least.  See original commit comment at

https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=8b9d323cb9810109e3e5aab1ead427cbbb7aa77e
        regards, tom lane