forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd6c08e2
committed
Add hash_mem_multiplier GUC.
Add a GUC that acts as a multiplier on work_mem. It gets applied whensizing executor node hash tables that were previously size constrainedusing work_mem alone.The new GUC can be used to preferentially give hash-based nodes morememory than the generic work_mem limit. It is intended to enable admintuning of the executor's memory usage. Overall system throughput andsystem responsiveness can be improved by giving hash-based executornodes more memory (especially over sort-based alternatives, which areoften much less sensitive to being memory constrained).The default value for hash_mem_multiplier is 1.0, which is also theminimum valid value. This means that hash-based nodes continue to applywork_mem in the traditional way by default.hash_mem_multiplier is generally useful. However, it is being added nowdue to concerns about hash aggregate performance stability for usersthat upgrade to Postgres 13 (which added disk-based hash aggregation incommit1f39bce). While the old hash aggregate behavior riskedout-of-memory errors, it is nevertheless likely that many users actuallybenefited. Hash agg's previous indifference to work_mem during queryexecution was not just faster; it also accidentally made aggregationresilient to grouping estimate problems (at least in cases where thisdidn't create destabilizing memory pressure).hash_mem_multiplier can provide a certain kind of continuity with thebehavior of Postgres 12 hash aggregates in cases where the plannerincorrectly estimates that all groups (plus related allocations) willfit in work_mem/hash_mem. This seems necessary because hash-basedaggregation is usually much slower when only a small fraction of allgroups can fit. Even when it isn't possible to totally avoid hashaggregates that spill, giving hash aggregation more memory will reliablyimprove performance (the same cannot be said for external sortoperations, which appear to be almost unaffected by memory availabilityprovided it's at least possible to get a single merge pass).The PostgreSQL 13 release notes should advise users that increasinghash_mem_multiplier can help with performance regressions associatedwith hash aggregation. That can be taken care of by a later commit.Author: Peter GeogheganReviewed-By: Álvaro Herrera, Jeff DavisDiscussion:https://postgr.es/m/20200625203629.7m6yvut7eqblgmfo@alap3.anarazel.deDiscussion:https://postgr.es/m/CAH2-WzmD%2Bi1pG6rc1%2BCjc4V6EaFJ_qSuKCCHVnH%3DoruqD-zqow%40mail.gmail.comBackpatch: 13-, where disk-based hash aggregation was introduced.1 parent6023b7e commitd6c08e2
File tree
19 files changed
+205
-81
lines changed- doc/src/sgml
- ref
- src
- backend
- executor
- optimizer
- path
- plan
- prep
- util
- utils
- adt
- init
- misc
- include
- executor
19 files changed
+205
-81
lines changedLines changed: 51 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1690 | 1690 |
| |
1691 | 1691 |
| |
1692 | 1692 |
| |
1693 |
| - | |
| 1693 | + | |
1694 | 1694 |
| |
1695 | 1695 |
| |
1696 | 1696 |
| |
1697 | 1697 |
| |
1698 |
| - | |
1699 |
| - | |
1700 |
| - | |
1701 |
| - | |
1702 |
| - | |
1703 |
| - | |
1704 |
| - | |
1705 |
| - | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
1706 | 1707 |
| |
1707 | 1708 |
| |
1708 | 1709 |
| |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
| 1747 | + | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
1709 | 1751 |
| |
1710 | 1752 |
| |
1711 | 1753 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
338 | 338 |
| |
339 | 339 |
| |
340 | 340 |
| |
341 |
| - | |
342 |
| - | |
343 |
| - | |
344 |
| - | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
345 | 345 |
| |
346 | 346 |
| |
347 | 347 |
| |
|
Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1326 | 1326 |
| |
1327 | 1327 |
| |
1328 | 1328 |
| |
1329 |
| - | |
1330 |
| - | |
1331 |
| - | |
1332 |
| - | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
1333 | 1335 |
| |
1334 | 1336 |
| |
1335 | 1337 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
165 | 165 |
| |
166 | 166 |
| |
167 | 167 |
| |
| 168 | + | |
168 | 169 |
| |
169 | 170 |
| |
170 | 171 |
| |
171 | 172 |
| |
172 | 173 |
| |
173 |
| - | |
174 |
| - | |
| 174 | + | |
| 175 | + | |
175 | 176 |
| |
176 | 177 |
| |
177 | 178 |
| |
|
Lines changed: 16 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
206 |
| - | |
| 206 | + | |
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
| |||
212 | 212 |
| |
213 | 213 |
| |
214 | 214 |
| |
215 |
| - | |
| 215 | + | |
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
| |||
1516 | 1516 |
| |
1517 | 1517 |
| |
1518 | 1518 |
| |
1519 |
| - | |
| 1519 | + | |
1520 | 1520 |
| |
1521 | 1521 |
| |
1522 | 1522 |
| |
| |||
1782 | 1782 |
| |
1783 | 1783 |
| |
1784 | 1784 |
| |
1785 |
| - | |
| 1785 | + | |
1786 | 1786 |
| |
1787 | 1787 |
| |
1788 | 1788 |
| |
| |||
1796 | 1796 |
| |
1797 | 1797 |
| |
1798 | 1798 |
| |
| 1799 | + | |
1799 | 1800 |
| |
1800 |
| - | |
1801 |
| - | |
| 1801 | + | |
| 1802 | + | |
1802 | 1803 |
| |
1803 | 1804 |
| |
1804 | 1805 |
| |
1805 |
| - | |
| 1806 | + | |
1806 | 1807 |
| |
1807 | 1808 |
| |
1808 | 1809 |
| |
| |||
1824 | 1825 |
| |
1825 | 1826 |
| |
1826 | 1827 |
| |
1827 |
| - | |
| 1828 | + | |
1828 | 1829 |
| |
1829 | 1830 |
| |
1830 | 1831 |
| |
1831 |
| - | |
1832 |
| - | |
| 1832 | + | |
| 1833 | + | |
1833 | 1834 |
| |
1834 |
| - | |
| 1835 | + | |
1835 | 1836 |
| |
1836 | 1837 |
| |
1837 | 1838 |
| |
| |||
1989 | 1990 |
| |
1990 | 1991 |
| |
1991 | 1992 |
| |
| 1993 | + | |
1992 | 1994 |
| |
1993 | 1995 |
| |
1994 | 1996 |
| |
1995 |
| - | |
| 1997 | + | |
1996 | 1998 |
| |
1997 | 1999 |
| |
1998 |
| - | |
| 2000 | + | |
1999 | 2001 |
| |
2000 | 2002 |
| |
2001 | 2003 |
| |
2002 | 2004 |
| |
2003 | 2005 |
| |
2004 |
| - | |
| 2006 | + | |
2005 | 2007 |
| |
2006 | 2008 |
| |
2007 | 2009 |
| |
|
Lines changed: 61 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
39 | 39 |
| |
40 | 40 |
| |
41 | 41 |
| |
| 42 | + | |
42 | 43 |
| |
43 | 44 |
| |
44 | 45 |
| |
| |||
506 | 507 |
| |
507 | 508 |
| |
508 | 509 |
| |
509 |
| - | |
| 510 | + | |
510 | 511 |
| |
511 | 512 |
| |
512 | 513 |
| |
| |||
665 | 666 |
| |
666 | 667 |
| |
667 | 668 |
| |
668 |
| - | |
| 669 | + | |
669 | 670 |
| |
670 | 671 |
| |
671 | 672 |
| |
| |||
682 | 683 |
| |
683 | 684 |
| |
684 | 685 |
| |
| 686 | + | |
685 | 687 |
| |
686 | 688 |
| |
687 | 689 |
| |
| |||
698 | 700 |
| |
699 | 701 |
| |
700 | 702 |
| |
701 |
| - | |
| 703 | + | |
702 | 704 |
| |
703 |
| - | |
| 705 | + | |
704 | 706 |
| |
705 | 707 |
| |
706 |
| - | |
707 |
| - | |
| 708 | + | |
| 709 | + | |
708 | 710 |
| |
709 | 711 |
| |
710 |
| - | |
| 712 | + | |
711 | 713 |
| |
712 | 714 |
| |
713 | 715 |
| |
| |||
728 | 730 |
| |
729 | 731 |
| |
730 | 732 |
| |
731 |
| - | |
| 733 | + | |
732 | 734 |
| |
733 | 735 |
| |
734 | 736 |
| |
| |||
751 | 753 |
| |
752 | 754 |
| |
753 | 755 |
| |
754 |
| - | |
| 756 | + | |
755 | 757 |
| |
756 | 758 |
| |
757 | 759 |
| |
| |||
790 | 792 |
| |
791 | 793 |
| |
792 | 794 |
| |
793 |
| - | |
794 |
| - | |
| 795 | + | |
| 796 | + | |
795 | 797 |
| |
796 |
| - | |
| 798 | + | |
797 | 799 |
| |
798 | 800 |
| |
799 | 801 |
| |
| |||
805 | 807 |
| |
806 | 808 |
| |
807 | 809 |
| |
808 |
| - | |
| 810 | + | |
809 | 811 |
| |
810 | 812 |
| |
811 | 813 |
| |
| |||
820 | 822 |
| |
821 | 823 |
| |
822 | 824 |
| |
823 |
| - | |
824 |
| - | |
| 825 | + | |
| 826 | + | |
825 | 827 |
| |
826 | 828 |
| |
827 | 829 |
| |
| |||
1095 | 1097 |
| |
1096 | 1098 |
| |
1097 | 1099 |
| |
| 1100 | + | |
| 1101 | + | |
1098 | 1102 |
| |
1099 | 1103 |
| |
1100 | 1104 |
| |
1101 |
| - | |
| 1105 | + | |
1102 | 1106 |
| |
1103 |
| - | |
| 1107 | + | |
1104 | 1108 |
| |
1105 | 1109 |
| |
1106 |
| - | |
| 1110 | + | |
1107 | 1111 |
| |
1108 | 1112 |
| |
1109 | 1113 |
| |
| |||
2855 | 2859 |
| |
2856 | 2860 |
| |
2857 | 2861 |
| |
2858 |
| - | |
| 2862 | + | |
2859 | 2863 |
| |
2860 | 2864 |
| |
2861 | 2865 |
| |
| |||
3366 | 3370 |
| |
3367 | 3371 |
| |
3368 | 3372 |
| |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + |
0 commit comments
Comments
(0)