On 2016/12/16 1:39, Tom Lane wrote:
> Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> writes:
>> On 2016/12/13 23:13, Ashutosh Bapat wrote:
>>> A possible short-term fix may be this: instead of picking any random
>>> path to stick into fdw_outerpath, we choose a path which covers the
>>> pathkeys of ForeignPath.
>> Seems reasonable.
> No, because GetExistingLocalJoinPath is called once per relation not once
> per path. Even if we were willing to eat the overhead of calling it once
> per path, we'd have to give up considering foreign paths with sort orders
> that there wasn't any cheap way to produce locally.
Hmm, I agree on that point that giving it up might result in a bad plan.
As I said upthread, an alternative I am thinking is (1) to create an
equivalent nestloop join path using inner/outer paths of a foreign join
path, except when that join path implements a full join, in which case a
merge/hash join path is used, (2) store it in fdw_outerpath as-is, and
(3) during an EPQ recheck, apply postgresRecheckForeignScan to the outer
subplan created from the fdw_outerpath as-is. What do you think about that?
Best regards,
Etsuro Fujita