diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 2bb6db1df7..0e22ac4903 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -5358,6 +5358,7 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel, { List *allclauses; double nrows; + double nrows2; /* * Estimate the number of rows returned by the parameterized scan, knowing @@ -5372,7 +5373,19 @@ get_parameterized_baserel_size(PlannerInfo *root, RelOptInfo *rel, rel->relid, /* do not use 0! */ JOIN_INNER, NULL); + + nrows2 = rel->rows * + clauselist_selectivity(root, + param_clauses, + rel->relid, /* do not use 0! */ + JOIN_INNER, + NULL); nrows = clamp_row_est(nrows); + nrows2 = clamp_row_est(nrows2); + + if (nrows != nrows2) + elog(NOTICE, "nrows = %g, nrows2 = %g", nrows, nrows2); + /* For safety, make sure result is not more than the base estimate */ if (nrows > rel->rows) nrows = rel->rows;