forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8c4040e
committed
Allocate hash join files in a separate memory context
Should a hash join exceed memory limit, the hashtable is split up intomultiple batches. The number of batches is doubled each time a givenbatch is determined not to fit in memory. Each batch file is allocatedwith a block-sized buffer for buffering tuples and parallel hash joinhas additional sharedtuplestore accessor buffers.In some pathological cases requiring a lot of batches, often with skeweddata, bad stats, or very large datasets, users can run out-of-memorysolely from the memory overhead of all the batch files' buffers.Batch files were allocated in the ExecutorState memory context, makingit very hard to identify when this batch explosion was the source of anOOM. This commit allocates the batch files in a dedicated memorycontext, making it easier to identify the cause of an OOM and work toavoid it.Based on initial draft by Tomas Vondra, with significant reworks andimprovements by Jehan-Guillaume de Rorthais.Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>Author: Tomas Vondra <tomas.vondra@enterprisedb.com>Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>Discussion:https://postgr.es/m/20190421114618.z3mpgmimc3rmubi4@developmentDiscussion:https://postgr.es/m/20230504193006.1b5b9622%40karst#273020ff4061fc7a2fbb1ba96b281f171 parent507615f commit8c4040e
File tree
5 files changed
+88
-29
lines changed- src
- backend
- executor
- utils/sort
- include/executor
5 files changed
+88
-29
lines changedLines changed: 33 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
484 | 484 |
| |
485 | 485 |
| |
486 | 486 |
| |
487 |
| - | |
| 487 | + | |
488 | 488 |
| |
489 | 489 |
| |
490 | 490 |
| |
| |||
538 | 538 |
| |
539 | 539 |
| |
540 | 540 |
| |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
541 | 545 |
| |
542 | 546 |
| |
543 | 547 |
| |
| |||
570 | 574 |
| |
571 | 575 |
| |
572 | 576 |
| |
| 577 | + | |
| 578 | + | |
573 | 579 |
| |
574 | 580 |
| |
575 | 581 |
| |
576 | 582 |
| |
| 583 | + | |
| 584 | + | |
577 | 585 |
| |
578 | 586 |
| |
| 587 | + | |
| 588 | + | |
| 589 | + | |
579 | 590 |
| |
580 | 591 |
| |
581 | 592 |
| |
| |||
913 | 924 |
| |
914 | 925 |
| |
915 | 926 |
| |
916 |
| - | |
917 | 927 |
| |
918 | 928 |
| |
919 | 929 |
| |
| |||
934 | 944 |
| |
935 | 945 |
| |
936 | 946 |
| |
937 |
| - | |
938 |
| - | |
939 | 947 |
| |
940 | 948 |
| |
| 949 | + | |
| 950 | + | |
941 | 951 |
| |
942 | 952 |
| |
943 | 953 |
| |
| 954 | + | |
| 955 | + | |
| 956 | + | |
944 | 957 |
| |
945 | 958 |
| |
946 | 959 |
| |
| |||
951 | 964 |
| |
952 | 965 |
| |
953 | 966 |
| |
954 |
| - | |
955 |
| - | |
956 | 967 |
| |
957 | 968 |
| |
958 | 969 |
| |
| |||
1024 | 1035 |
| |
1025 | 1036 |
| |
1026 | 1037 |
| |
1027 |
| - | |
| 1038 | + | |
| 1039 | + | |
1028 | 1040 |
| |
1029 | 1041 |
| |
1030 | 1042 |
| |
| |||
1683 | 1695 |
| |
1684 | 1696 |
| |
1685 | 1697 |
| |
1686 |
| - | |
| 1698 | + | |
| 1699 | + | |
1687 | 1700 |
| |
1688 | 1701 |
| |
1689 | 1702 |
| |
| |||
2664 | 2677 |
| |
2665 | 2678 |
| |
2666 | 2679 |
| |
2667 |
| - | |
| 2680 | + | |
| 2681 | + | |
2668 | 2682 |
| |
2669 | 2683 |
| |
2670 | 2684 |
| |
| |||
3093 | 3107 |
| |
3094 | 3108 |
| |
3095 | 3109 |
| |
3096 |
| - | |
3097 |
| - | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
3098 | 3115 |
| |
3099 | 3116 |
| |
3100 | 3117 |
| |
| |||
3196 | 3213 |
| |
3197 | 3214 |
| |
3198 | 3215 |
| |
3199 |
| - | |
3200 |
| - | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
3201 | 3221 |
| |
3202 | 3222 |
| |
3203 | 3223 |
| |
|
Lines changed: 25 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
495 | 495 |
| |
496 | 496 |
| |
497 | 497 |
| |
498 |
| - | |
| 498 | + | |
| 499 | + | |
499 | 500 |
| |
500 | 501 |
| |
501 | 502 |
| |
| |||
1317 | 1318 |
| |
1318 | 1319 |
| |
1319 | 1320 |
| |
1320 |
| - | |
1321 |
| - | |
1322 |
| - | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
1323 | 1325 |
| |
1324 | 1326 |
| |
1325 | 1327 |
| |
1326 |
| - | |
| 1328 | + | |
1327 | 1329 |
| |
1328 | 1330 |
| |
1329 | 1331 |
| |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
1330 | 1346 |
| |
1331 | 1347 |
| |
1332 |
| - | |
| 1348 | + | |
| 1349 | + | |
1333 | 1350 |
| |
1334 | 1351 |
| |
| 1352 | + | |
| 1353 | + | |
1335 | 1354 |
| |
1336 | 1355 |
| |
1337 | 1356 |
| |
|
Lines changed: 8 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
308 | 308 |
| |
309 | 309 |
| |
310 | 310 |
| |
| 311 | + | |
311 | 312 |
| |
312 | 313 |
| |
313 | 314 |
| |
| 315 | + | |
| 316 | + | |
314 | 317 |
| |
315 | 318 |
| |
| 319 | + | |
316 | 320 |
| |
317 | 321 |
| |
318 | 322 |
| |
| |||
527 | 531 |
| |
528 | 532 |
| |
529 | 533 |
| |
| 534 | + | |
530 | 535 |
| |
531 | 536 |
| |
| 537 | + | |
| 538 | + | |
532 | 539 |
| |
533 | 540 |
| |
534 | 541 |
| |
| 542 | + | |
535 | 543 |
| |
536 | 544 |
| |
537 | 545 |
| |
|
Lines changed: 21 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
26 |
| - | |
27 |
| - | |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
37 | 37 |
| |
38 | 38 |
| |
39 |
| - | |
40 |
| - | |
41 |
| - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
42 | 53 |
| |
43 | 54 |
| |
44 | 55 |
| |
| |||
350 | 361 |
| |
351 | 362 |
| |
352 | 363 |
| |
| 364 | + | |
353 | 365 |
| |
354 | 366 |
| |
355 | 367 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
29 | 29 |
| |
30 | 30 |
| |
31 | 31 |
| |
32 |
| - | |
| 32 | + | |
33 | 33 |
| |
34 | 34 |
|
0 commit comments
Comments
(0)