forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0ff865f
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-bap781 parente1c02d9 commit0ff865f
1 file changed
+7
-1
lines changedLines changed: 7 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1391 | 1391 |
| |
1392 | 1392 |
| |
1393 | 1393 |
| |
1394 |
| - | |
| 1394 | + | |
1395 | 1395 |
| |
1396 | 1396 |
| |
1397 | 1397 |
| |
| |||
1404 | 1404 |
| |
1405 | 1405 |
| |
1406 | 1406 |
| |
| 1407 | + | |
1407 | 1408 |
| |
1408 | 1409 |
| |
1409 | 1410 |
| |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
1410 | 1416 |
| |
1411 | 1417 |
| |
1412 | 1418 |
| |
|
0 commit comments
Comments
(0)