forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6cb8614
committed
Allow aggregates to provide estimates of their transition state data size.
Formerly the planner had a hard-wired rule of thumb for guessing the amountof space consumed by an aggregate function's transition state data. Thisestimate is critical to deciding whether it's OK to use hash aggregation,and in many situations the built-in estimate isn't very good. This patchadds a column to pg_aggregate wherein a per-aggregate estimate can beprovided, overriding the planner's default, and infrastructure for settingthe column via CREATE AGGREGATE.It may be that additional smarts will be required in future, perhaps evena per-aggregate estimation function. But this is already a step forward.This is extracted from a larger patch to improve the performance of numericand int8 aggregates. I (tgl) thought it was worth reviewing and committingthis infrastructure separately. In this commit, all built-in aggregatesare given aggtransspace = 0, so no behavior should change.Hadi Moshayedi, reviewed by Pavel Stehule and Tomas Vondra1 parent55c3d86 commit6cb8614
File tree
14 files changed
+245
-147
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- optimizer/util
- bin/pg_dump
- include
- catalog
- commands
- test/regress
- expected
- sql
14 files changed
+245
-147
lines changedLines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
372 | 372 |
| |
373 | 373 |
| |
374 | 374 |
| |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
375 | 382 |
| |
376 | 383 |
| |
377 | 384 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
24 | 24 |
| |
25 | 25 |
| |
26 | 26 |
| |
| 27 | + | |
27 | 28 |
| |
28 | 29 |
| |
29 | 30 |
| |
| |||
35 | 36 |
| |
36 | 37 |
| |
37 | 38 |
| |
| 39 | + | |
38 | 40 |
| |
39 | 41 |
| |
40 | 42 |
| |
| |||
264 | 266 |
| |
265 | 267 |
| |
266 | 268 |
| |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
267 | 285 |
| |
268 | 286 |
| |
269 | 287 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| 58 | + | |
58 | 59 |
| |
59 | 60 |
| |
60 | 61 |
| |
| |||
273 | 274 |
| |
274 | 275 |
| |
275 | 276 |
| |
| 277 | + | |
276 | 278 |
| |
277 | 279 |
| |
278 | 280 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| 63 | + | |
63 | 64 |
| |
64 | 65 |
| |
65 | 66 |
| |
| |||
102 | 103 |
| |
103 | 104 |
| |
104 | 105 |
| |
| 106 | + | |
| 107 | + | |
105 | 108 |
| |
106 | 109 |
| |
107 | 110 |
| |
| |||
248 | 251 |
| |
249 | 252 |
| |
250 | 253 |
| |
| 254 | + | |
251 | 255 |
| |
252 | 256 |
|
Lines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
164 | 164 |
| |
165 | 165 |
| |
166 | 166 |
| |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
167 | 191 |
| |
168 | 192 |
| |
169 | 193 |
| |
|
Lines changed: 27 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
461 | 461 |
| |
462 | 462 |
| |
463 | 463 |
| |
| 464 | + | |
464 | 465 |
| |
465 | 466 |
| |
466 | 467 |
| |
| |||
478 | 479 |
| |
479 | 480 |
| |
480 | 481 |
| |
| 482 | + | |
481 | 483 |
| |
482 | 484 |
| |
483 | 485 |
| |
| |||
541 | 543 |
| |
542 | 544 |
| |
543 | 545 |
| |
544 |
| - | |
545 | 546 |
| |
546 | 547 |
| |
547 |
| - | |
548 |
| - | |
549 |
| - | |
550 |
| - | |
551 |
| - | |
552 |
| - | |
553 |
| - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
554 | 551 |
| |
555 |
| - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
556 | 560 |
| |
557 |
| - | |
558 |
| - | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
559 | 568 |
| |
| 569 | + | |
560 | 570 |
| |
561 | 571 |
| |
562 | 572 |
| |
563 | 573 |
| |
564 | 574 |
| |
565 | 575 |
| |
566 | 576 |
| |
567 |
| - | |
| 577 | + | |
| 578 | + | |
568 | 579 |
| |
569 | 580 |
| |
570 | 581 |
| |
571 | 582 |
| |
572 |
| - | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
573 | 587 |
| |
574 | 588 |
| |
575 | 589 |
| |
|
Lines changed: 30 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
11521 | 11521 |
| |
11522 | 11522 |
| |
11523 | 11523 |
| |
| 11524 | + | |
11524 | 11525 |
| |
11525 | 11526 |
| |
11526 | 11527 |
| |
11527 | 11528 |
| |
11528 | 11529 |
| |
11529 | 11530 |
| |
| 11531 | + | |
11530 | 11532 |
| |
11531 | 11533 |
| |
11532 | 11534 |
| |
| |||
11544 | 11546 |
| |
11545 | 11547 |
| |
11546 | 11548 |
| |
11547 |
| - | |
| 11549 | + | |
| 11550 | + | |
| 11551 | + | |
| 11552 | + | |
| 11553 | + | |
| 11554 | + | |
| 11555 | + | |
| 11556 | + | |
| 11557 | + | |
| 11558 | + | |
| 11559 | + | |
| 11560 | + | |
| 11561 | + | |
| 11562 | + | |
| 11563 | + | |
11548 | 11564 |
| |
11549 | 11565 |
| |
11550 | 11566 |
| |
11551 | 11567 |
| |
11552 |
| - | |
| 11568 | + | |
11553 | 11569 |
| |
11554 | 11570 |
| |
11555 | 11571 |
| |
| |||
11563 | 11579 |
| |
11564 | 11580 |
| |
11565 | 11581 |
| |
11566 |
| - | |
| 11582 | + | |
11567 | 11583 |
| |
11568 | 11584 |
| |
11569 | 11585 |
| |
| |||
11575 | 11591 |
| |
11576 | 11592 |
| |
11577 | 11593 |
| |
11578 |
| - | |
| 11594 | + | |
11579 | 11595 |
| |
11580 | 11596 |
| |
11581 | 11597 |
| |
| |||
11587 | 11603 |
| |
11588 | 11604 |
| |
11589 | 11605 |
| |
11590 |
| - | |
| 11606 | + | |
11591 | 11607 |
| |
11592 | 11608 |
| |
11593 | 11609 |
| |
| |||
11599 | 11615 |
| |
11600 | 11616 |
| |
11601 | 11617 |
| |
11602 |
| - | |
| 11618 | + | |
11603 | 11619 |
| |
11604 | 11620 |
| |
11605 | 11621 |
| |
| |||
11612 | 11628 |
| |
11613 | 11629 |
| |
11614 | 11630 |
| |
| 11631 | + | |
11615 | 11632 |
| |
11616 | 11633 |
| |
11617 | 11634 |
| |
11618 | 11635 |
| |
11619 | 11636 |
| |
11620 | 11637 |
| |
11621 | 11638 |
| |
| 11639 | + | |
11622 | 11640 |
| |
11623 | 11641 |
| |
11624 | 11642 |
| |
| |||
11672 | 11690 |
| |
11673 | 11691 |
| |
11674 | 11692 |
| |
| 11693 | + | |
| 11694 | + | |
| 11695 | + | |
| 11696 | + | |
| 11697 | + | |
| 11698 | + | |
11675 | 11699 |
| |
11676 | 11700 |
| |
11677 | 11701 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
53 | 53 |
| |
54 | 54 |
| |
55 | 55 |
| |
56 |
| - | |
| 56 | + | |
57 | 57 |
| |
58 | 58 |
|
0 commit comments
Comments
(0)