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
