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

Commit69995c3

Browse files
committed
Fix cost_rescan() to account for multi-batch hashing correctly.
cost_rescan assumed that we don't need to rebuild the hash table whenrescanning a hash join. However, that's currently only true forsingle-batch joins; for a multi-batch join we must charge full freight.This probably has escaped notice because we'd be unlikely to put a hashjoin on the inside of a nestloop anyway. Nonetheless, it's wrong.Fix in HEAD, but don't backpatch for fear of destabilizing plans instable releases.
1 parentb31875b commit69995c3

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,11 +3114,21 @@ cost_rescan(PlannerInfo *root, Path *path,
31143114
caseT_HashJoin:
31153115

31163116
/*
3117-
*Assume that all of the startup cost represents hash table
3118-
*building, which we won't have to do over.
3117+
*If it's a single-batch join, we don't need to rebuild the hash
3118+
*table during a rescan.
31193119
*/
3120-
*rescan_startup_cost=0;
3121-
*rescan_total_cost=path->total_cost-path->startup_cost;
3120+
if (((HashPath*)path)->num_batches==1)
3121+
{
3122+
/* Startup cost is exactly the cost of hash table building */
3123+
*rescan_startup_cost=0;
3124+
*rescan_total_cost=path->total_cost-path->startup_cost;
3125+
}
3126+
else
3127+
{
3128+
/* Otherwise, no special treatment */
3129+
*rescan_startup_cost=path->startup_cost;
3130+
*rescan_total_cost=path->total_cost;
3131+
}
31223132
break;
31233133
caseT_CteScan:
31243134
caseT_WorkTableScan:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp