forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit069d0ff

Richard Guo
Check lateral references within PHVs for memoize cache keys
If we intend to generate a Memoize node on top of a path, we needcache keys of some sort. Currently we search for the cache keys inthe parameterized clauses of the path as well as the lateral_vars ofits parent. However, it turns out that this is not sufficient becausethere might be lateral references derived from PlaceHolderVars, whichwe fail to take into consideration.This oversight can cause us to miss opportunities to utilize theMemoize node. Moreover, in some plans, failing to recognize all thecache keys could result in performance regressions. This is becausewithout identifying all the cache keys, we would need to purge theentire cache every time we get a new outer tuple during execution.This patch fixes this issue by extracting lateral Vars from withinPlaceHolderVars and subsequently including them in the cache keys.In passing, this patch also includes a comment clarifying that Memoizenodes are currently not added on top of join relation paths. Thisexplains why this patch only considers PlaceHolderVars that are due tobe evaluated at baserels.Author: Richard GuoReviewed-by: Tom Lane, David Rowley, Andrei LepikhovDiscussion:https://postgr.es/m/CAMbWs48jLxn0pAPZpJ50EThZ569Xrw+=4Ac3QvkpQvNszbeoNg@mail.gmail.com1 parentf96c2c7 commit069d0ff
File tree
4 files changed
+245
-9
lines changed- contrib/postgres_fdw/expected
- src
- backend/optimizer/path
- test/regress
- expected
- sql
4 files changed
+245
-9
lines changedLines changed: 8 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3774 | 3774 |
| |
3775 | 3775 |
| |
3776 | 3776 |
| |
3777 |
| - | |
3778 |
| - | |
3779 |
| - | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
3780 | 3784 |
| |
3781 | 3785 |
| |
3782 | 3786 |
| |
3783 | 3787 |
| |
3784 | 3788 |
| |
3785 |
| - | |
| 3789 | + | |
3786 | 3790 |
| |
3787 | 3791 |
| |
3788 | 3792 |
| |
|
Lines changed: 109 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
425 | 426 |
| |
426 | 427 |
| |
427 | 428 |
| |
428 |
| - | |
| 429 | + | |
429 | 430 |
| |
430 | 431 |
| |
431 | 432 |
| |
| |||
438 | 439 |
| |
439 | 440 |
| |
440 | 441 |
| |
441 |
| - | |
442 |
| - | |
| 442 | + | |
| 443 | + | |
443 | 444 |
| |
444 | 445 |
| |
| 446 | + | |
445 | 447 |
| |
446 | 448 |
| |
447 | 449 |
| |
| |||
521 | 523 |
| |
522 | 524 |
| |
523 | 525 |
| |
524 |
| - | |
| 526 | + | |
| 527 | + | |
525 | 528 |
| |
526 | 529 |
| |
527 | 530 |
| |
| |||
572 | 575 |
| |
573 | 576 |
| |
574 | 577 |
| |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
575 | 663 |
| |
576 | 664 |
| |
577 | 665 |
| |
578 | 666 |
| |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
579 | 673 |
| |
580 | 674 |
| |
581 | 675 |
| |
| |||
587 | 681 |
| |
588 | 682 |
| |
589 | 683 |
| |
| 684 | + | |
590 | 685 |
| |
591 | 686 |
| |
592 | 687 |
| |
| |||
601 | 696 |
| |
602 | 697 |
| |
603 | 698 |
| |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
604 | 706 |
| |
605 | 707 |
| |
606 | 708 |
| |
607 | 709 |
| |
608 | 710 |
| |
609 | 711 |
| |
610 | 712 |
| |
611 |
| - | |
| 713 | + | |
| 714 | + | |
612 | 715 |
| |
613 | 716 |
| |
614 | 717 |
| |
| |||
695 | 798 |
| |
696 | 799 |
| |
697 | 800 |
| |
| 801 | + | |
698 | 802 |
| |
699 | 803 |
| |
700 | 804 |
| |
|
Lines changed: 93 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
129 | 129 |
| |
130 | 130 |
| |
131 | 131 |
| |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 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 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
132 | 225 |
| |
133 | 226 |
| |
134 | 227 |
| |
|
Lines changed: 35 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
77 | 112 |
| |
78 | 113 |
| |
79 | 114 |
| |
|
0 commit comments
Comments
(0)