Re: [PATCH] postgres_fdw: Fix cost estimation for semi join pushdown
Re: [PATCH] postgres_fdw: Fix cost estimation for semi join pushdown
От:
"ChenhuiMo" <chenhuimo.mch@qq.com>
Дата:
Hi Ziming, I reviewed v2, and the fix looks correct to me. For JOIN_SEMI, joinclause_sel represents the fraction of outer rows having a match, so using the outer row count here is consistent with the selectivity semantics and the core semi-join size estimation. The placement of the change also looks appropriate: it corrects the row count used to charge remote_conds_cost, while retaining the existing estimate for evaluating the join clauses. The path's output row estimate still comes from foreignrel->rows. The revised regression test looks useful, especially given your check that reverting only the code change makes it fail. That gives it coverage of this costing issue beyond checking that semi-join pushdown is supported. One small comment nit: the new comment refers to foreign_join_ok(), but joinclause_sel is actually computed in postgresGetForeignJoinPaths(). The reference to the local_conds selectivity calculation in the commit message could be adjusted similarly. Apart from that, I have no further comments from code inspection. I also applied the patch to my local PostgreSQL tree and ran make check, which passed. Apart from the comment nit above, the patch looks good to me. One small request for future replies: please avoid quoting the entire original message; keeping only the relevant parts would make the thread easier to follow. Please also use English for replies, including "Re:" rather than a localized subject prefix, so that everyone on the list can follow the discussion. Regards, ChenHui Mo
Re: [PATCH] postgres_fdw: Fix cost estimation for semi join pushdown
От:
solai v <solai.cdac@gmail.com>
Дата:
Hi all, Thank you for the updated v2 patch. I reproduced the issue using the provided test case. With the unpatched code, the planner chose a local Hash Semi Join, followed by Sort and Limit, instead of pushing down the semi-join. After applying the patch, the planner selected a single Foreign Scan, with the semi-join, filters, ORDER BY, LIMIT, and OFFSET pushed down to the remote server as intended. I also ran the postgres_fdw regression tests, including postgres_fdw and query_cancel, along with the eval_plan_qual isolation test. All three tests passed. The change looks good to me. Thank you for addressing this issue. Regards, Solai