diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index 4c30c65564..d57a56833d 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -527,12 +527,31 @@ get_resultcache_path(PlannerInfo *root, RelOptInfo *innerrel, ¶m_exprs, &hash_operators)) { + bool singlerow; + + /* + * Determine if the executor can mark cache entries as complete after + * pulling the first tuple from the result cache's subplan. It's + * possible to do this when the join has been marked as unique and the + * entire join condition is parameterized. If part of the join + * condition will only be evaluated as part of the join filter then + * we may cache multiple tuples per entry so the executor will be + * unable to mark entries as complete after storing the first tuple. + */ + if (!extra->inner_unique) + singlerow = false; + else if (list_length(extra->restrictlist) == + list_length(inner_path->param_info->ppi_clauses)) + singlerow = true; /* all join quals present in param info */ + else + singlerow = false; + return (Path *) create_resultcache_path(root, innerrel, inner_path, param_exprs, hash_operators, - extra->inner_unique, + singlerow, outer_path->parent->rows); }