Robert Haas <robertmhaas@gmail.com> writes:
> On Tue, Sep 5, 2017 at 4:34 AM, Amit Kapila <amit.kapila16@gmail.com> wrote:
>> Okay, now I understand your point, but I think we already change the
>> cost of paths in apply_projection_to_path which is done after add_path
>> for top level scan/join paths.
> Yeah. I think that's a nasty hack, and I think it's Tom's fault. :-)
Yeah, and it's also documented:
* This has the same net effect as create_projection_path(), except that if* a separate Result plan node isn't needed,
wejust replace the given path's* pathtarget with the desired one. This must be used only when the caller* knows that
thegiven path isn't referenced elsewhere and so can be modified* in-place.
If somebody's applying apply_projection_to_path to a path that's already
been add_path'd, that's a violation of the documented restriction.
It might be that we should just get rid of apply_projection_to_path and
use create_projection_path, which is less mistake-prone at the cost of
manufacturing another level of Path node. Now that that has the dummypp
flag, it really shouldn't make any difference in terms of the accuracy of
the cost estimates.
> I'd feel a lot happier if Tom were to decide how this ought to be
> fixed, because - in spite of some modifications by various parallel
> query code - this is basically all his design and mostly his code.
I can take a look, but not right away.
regards, tom lane