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

Commit0ff865f

Browse files
committed
Fix bug in HashAgg's selective-column-spilling logic.
Commit2302302 taught nodeAgg.c that, when spilling tuples frommemory in an oversized hash aggregation, it only needed to spillinput columns referenced in the node's tlist and quals. Unfortunately,that's wrong: we also have to save the grouping columns. The erroris masked in common cases because the grouping columns also appearin the tlist, but that's not necessarily true. The main categoryof plans where it's not true seem to come from semijoins ("WHEREoutercol IN (SELECT innercol FROM innertable)") where the innercolneeds an implicit promotion to make it comparable to the outercol.The grouping column will be "innercol::promotedtype", but thatexpression appears nowhere in the Agg node's own tlist and quals;only the bare "innercol" is found in the tlist.I spent quite a bit of time looking for a suitable regression testcase for this, without much success. If the number of distinctvalues of the innercol is large enough to make spilling happen,the planner tends to prefer a non-HashAgg plan, at least forproblem sizes that are reasonable to use in the regression tests.So, no new regression test. However, this patch does demonstrablyfix the originally-reported test case.Per report from s.p.e (at) gmx-topmail.de. Backpatch to v13where the troublesome code came in.Discussion:https://postgr.es/m/trinity-1c565d44-159f-488b-a518-caf13883134f-1611835701633@3c-app-gmx-bap78
1 parente1c02d9 commit0ff865f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎src/backend/executor/nodeAgg.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ project_aggregates(AggState *aggstate)
13911391
}
13921392

13931393
/*
1394-
*Walk tlist and qual to find referenced colnos, dividing them into
1394+
*Find input-tuple columns that are needed, dividing them into
13951395
* aggregated and unaggregated sets.
13961396
*/
13971397
staticvoid
@@ -1404,9 +1404,15 @@ find_cols(AggState *aggstate, Bitmapset **aggregated, Bitmapset **unaggregated)
14041404
context.aggregated=NULL;
14051405
context.unaggregated=NULL;
14061406

1407+
/* Examine tlist and quals */
14071408
(void)find_cols_walker((Node*)agg->plan.targetlist,&context);
14081409
(void)find_cols_walker((Node*)agg->plan.qual,&context);
14091410

1411+
/* In some cases, grouping columns will not appear in the tlist */
1412+
for (inti=0;i<agg->numCols;i++)
1413+
context.unaggregated=bms_add_member(context.unaggregated,
1414+
agg->grpColIdx[i]);
1415+
14101416
*aggregated=context.aggregated;
14111417
*unaggregated=context.unaggregated;
14121418
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp