diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index f8cc7f387c81..debb2fdd6602 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -112,14 +112,6 @@ */ #define APPEND_CPU_COST_MULTIPLIER 0.5 -/* - * Maximum value for row estimates. We cap row estimates to this to help - * ensure that costs based on these estimates remain within the range of what - * double can represent. add_path() wouldn't act sanely given infinite or NaN - * cost values. - */ -#define MAXIMUM_ROWCOUNT 1e100 - double seq_page_cost = DEFAULT_SEQ_PAGE_COST; double random_page_cost = DEFAULT_RANDOM_PAGE_COST; double cpu_tuple_cost = DEFAULT_CPU_TUPLE_COST; @@ -234,26 +226,11 @@ static Selectivity adjust_selectivity_for_nulltest(Selectivity selec, */ typedef struct { -<<<<<<< HEAD /* Values copied from RelOptInfo as is, for convenience */ Index relid; RTEKind rtekind; /* RELATION, SUBQUERY, or FUNCTION */ Oid reltablespace; /* containing tablespace */ double allvisfrac; -======= - /* - * Avoid infinite and NaN row estimates. Costs derived from such values - * are going to be useless. Also force the estimate to be at least one - * row, to make explain output look better and to avoid possible - * divide-by-zero when interpolating costs. Make it an integer, too. - */ - if (nrows > MAXIMUM_ROWCOUNT || isnan(nrows)) - nrows = MAXIMUM_ROWCOUNT; - else if (nrows <= 1.0) - nrows = 1.0; - else - nrows = rint(nrows); ->>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d /* Values adjusted from RelOptInfo, by dividing by numsegments */ double rows; @@ -3035,15 +3012,12 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path, outer_path_rows = 1; if (inner_path_rows <= 0) inner_path_rows = 1; -<<<<<<< HEAD if (CdbPathLocus_IsPartitioned(path->path.locus)) numsegments = CdbPathLocus_NumSegments(path->path.locus); else numsegments = 1; -======= ->>>>>>> f81e97d0475cd4bc597adc23b665bd84fbf79a0d /* Mark the path with the correct row estimate */ if (path->path.param_info) path->path.rows = path->path.param_info->ppi_rows; diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index dd1c5c41a21c..a722750f339b 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -33,6 +33,14 @@ #define DEFAULT_EFFECTIVE_CACHE_SIZE 524288 /* measured in pages */ +/* + * Maximum value for row estimates. We cap row estimates to this to help + * ensure that costs based on these estimates remain within the range of what + * double can represent. add_path() wouldn't act sanely given infinite or NaN + * cost values. + */ +#define MAXIMUM_ROWCOUNT 1e100 + typedef enum { CONSTRAINT_EXCLUSION_OFF, /* do not use c_e */ @@ -49,11 +57,18 @@ static inline double clamp_row_est(double nrows) { /* - * Force estimate to be at least one row, to make explain output look - * better and to avoid possible divide-by-zero when interpolating costs. + * Avoid infinite and NaN row estimates. Costs derived from such values + * are going to be useless. Also force the estimate to be at least one + * row, to make explain output look better and to avoid possible + * divide-by-zero when interpolating costs. * CDB: Don't round to integer. */ - return (nrows < 1.0) ? 1.0 : nrows; + if (nrows > MAXIMUM_ROWCOUNT || isnan(nrows)) + nrows = MAXIMUM_ROWCOUNT; + else if (nrows < 1.0) + nrows = 1.0; + + return nrows; }