Skip to content

Commit

Permalink
Fix failure to use clamp_row_est() for parallel joins.
Browse files Browse the repository at this point in the history
Commit 0c2070c neglected to use
clamp_row_est() where it should have done so.

Patch by me.  Report by Amit Kapila.

Discussion: http://postgr.es/m/CAA4eK1KPm8RYa1Kun3ZmQj9pb723b-EFN70j47Pid1vn3ByquA@mail.gmail.com
  • Loading branch information
robertmhaas committed Mar 15, 2017
1 parent 18dc2ae commit 5feb78a
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/backend/optimizer/path/costsize.c
Expand Up @@ -1998,7 +1998,12 @@ final_cost_nestloop(PlannerInfo *root, NestPath *path,

/* For partial paths, scale row estimate. */
if (path->path.parallel_workers > 0)
path->path.rows /= get_parallel_divisor(&path->path);
{
double parallel_divisor = get_parallel_divisor(&path->path);

path->path.rows =
clamp_row_est(path->path.rows / parallel_divisor);
}

/*
* We could include disable_cost in the preliminary estimate, but that
Expand Down Expand Up @@ -2420,7 +2425,12 @@ final_cost_mergejoin(PlannerInfo *root, MergePath *path,

/* For partial paths, scale row estimate. */
if (path->jpath.path.parallel_workers > 0)
path->jpath.path.rows /= get_parallel_divisor(&path->jpath.path);
{
double parallel_divisor = get_parallel_divisor(&path->jpath.path);

path->jpath.path.rows =
clamp_row_est(path->jpath.path.rows / parallel_divisor);
}

/*
* We could include disable_cost in the preliminary estimate, but that
Expand Down Expand Up @@ -2803,7 +2813,12 @@ final_cost_hashjoin(PlannerInfo *root, HashPath *path,

/* For partial paths, scale row estimate. */
if (path->jpath.path.parallel_workers > 0)
path->jpath.path.rows /= get_parallel_divisor(&path->jpath.path);
{
double parallel_divisor = get_parallel_divisor(&path->jpath.path);

path->jpath.path.rows =
clamp_row_est(path->jpath.path.rows / parallel_divisor);
}

/*
* We could include disable_cost in the preliminary estimate, but that
Expand Down

0 comments on commit 5feb78a

Please sign in to comment.