Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit77ca44b

Browse files
committed
Relax some asserts in merge join costing code
In the planner, it was possible, given an extreme enough case containing alarge number of joins for the number of estimated rows to become infinite.This could cause problems in initial_cost_mergejoin() where we performsome calculations based on those row estimates.A problem case, presented by Onder Kalaci showed an Assert failure froman Assert checking outerstartsel <= outerendsel. In his test case thiswas effectively NaN <= Inf, which is false. The NaN outerstartsel camefrom multiplying the infinite outer_path_rows by 0.0.In master, this problem was fixed bya90c950, however, that fix was tooinvasive for the backbranches. Here we just relax the Asserts to allowthem to pass. The worst that appears to happen from this is that we showNaN cost values and infinite row estimates in EXPLAIN. add_path() wouldhave had a hard time doing anything useful with such costs, but that doesnot really matter as if the row estimates were even close to accurate,such plan would not complete this side of the heat death of the universe.Reported-by: Onder KalaciBackpatch: 9.5 to 13Discussion:https://postgr.es/m/DM6PR21MB1211FF360183BCA901B27F04D80B0@DM6PR21MB1211.namprd21.prod.outlook.com
1 parent57bdf29 commit77ca44b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

‎src/backend/optimizer/path/costsize.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,8 +2805,9 @@ initial_cost_mergejoin(PlannerInfo *root, JoinCostWorkspace *workspace,
28052805
outer_rows=clamp_row_est(outer_path_rows*outerendsel);
28062806
inner_rows=clamp_row_est(inner_path_rows*innerendsel);
28072807

2808-
Assert(outer_skip_rows <=outer_rows);
2809-
Assert(inner_skip_rows <=inner_rows);
2808+
/* skip rows can become NaN when path rows has become infinite */
2809+
Assert(outer_skip_rows <=outer_rows||isnan(outer_skip_rows));
2810+
Assert(inner_skip_rows <=inner_rows||isnan(inner_skip_rows));
28102811

28112812
/*
28122813
* Readjust scan selectivities to account for above rounding. This is
@@ -2818,8 +2819,9 @@ initial_cost_mergejoin(PlannerInfo *root, JoinCostWorkspace *workspace,
28182819
outerendsel=outer_rows /outer_path_rows;
28192820
innerendsel=inner_rows /inner_path_rows;
28202821

2821-
Assert(outerstartsel <=outerendsel);
2822-
Assert(innerstartsel <=innerendsel);
2822+
/* start sel can become NaN when path rows has become infinite */
2823+
Assert(outerstartsel <=outerendsel||isnan(outerstartsel));
2824+
Assert(innerstartsel <=innerendsel||isnan(innerstartsel));
28232825

28242826
/* cost of source data */
28252827

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp