aboutsummaryrefslogtreecommitdiff
path: root/src/include/optimizer/cost.h
diff options
context:
space:
mode:
authorRichard Guo <rguo@postgresql.org>2024-07-23 10:33:26 +0900
committerRichard Guo <rguo@postgresql.org>2024-07-23 10:33:26 +0900
commit581df2148737fdb0ba6f2d8fda5ceb9d1e6302e6 (patch)
tree908998effc2d0cc771ce3bea2a2130736479a6cd /src/include/optimizer/cost.h
parentd2cba4f2cbfe69b2c5f93f364da4e574e075cb03 (diff)
downloadpostgresql-581df2148737fdb0ba6f2d8fda5ceb9d1e6302e6.tar.gz
postgresql-581df2148737fdb0ba6f2d8fda5ceb9d1e6302e6.zip
Fix rowcount estimate for gather (merge) paths
In the case of a parallel plan, when computing the number of tuples processed per worker, we divide the total number of tuples by the parallel_divisor obtained from get_parallel_divisor(), which accounts for the leader's contribution in addition to the number of workers. Accordingly, when estimating the number of tuples for gather (merge) nodes, we should multiply the number of tuples per worker by the same parallel_divisor to reverse the division. However, currently we use parallel_workers rather than parallel_divisor for the multiplication. This could result in an underestimation of the number of tuples for gather (merge) nodes, especially when there are fewer than four workers. This patch fixes this issue by using the same parallel_divisor for the multiplication. There is one ensuing plan change in the regression tests, but it looks reasonable and does not compromise its original purpose of testing parallel-aware hash join. In passing, this patch removes an unnecessary assignment for path.rows in create_gather_merge_path, and fixes an uninitialized-variable issue in generate_useful_gather_paths. No backpatch as this could result in plan changes. Author: Anthonin Bonnefoy Reviewed-by: Rafia Sabih, Richard Guo Discussion: https://postgr.es/m/CAO6_Xqr9+51NxgO=XospEkUeAg-p=EjAWmtpdcZwjRgGKJ53iA@mail.gmail.com
Diffstat (limited to 'src/include/optimizer/cost.h')
-rw-r--r--src/include/optimizer/cost.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index b1c51a4e70f..57861bfb446 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -212,5 +212,6 @@ extern PathTarget *set_pathtarget_cost_width(PlannerInfo *root, PathTarget *targ
extern double compute_bitmap_pages(PlannerInfo *root, RelOptInfo *baserel,
Path *bitmapqual, double loop_count,
Cost *cost_p, double *tuples_p);
+extern double compute_gather_rows(Path *path);
#endif /* COST_H */