- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitcb8e50a
committed
Avoid inserting PlaceHolderVars in cases where pre-v16 PG did not.
Commit2489d76 removed some logic from pullup_replace_vars()that avoided wrapping a PlaceHolderVar around a pulled-upsubquery output expression if the expression could be provento go to NULL anyway (because it contained Vars or PHVs of thepulled-up relation and did not contain non-strict constructs).But removing that logic turns out to cause performance regressionsin some cases, because the extra PHV blocks subexpression folding,and will do so even if outer-join reduction later turns it into ano-op with no phnullingrels bits. This can for example preventan expression from being matched to an index.The reason for always adding a PHV was to ensure we had someplaceto put the varnullingrels marker bits of the Var being replaced.However, it turns out we can optimize in exactly the same cases thatthe previous code did, because we can instead attach the neededvarnullingrels bits to the contained Var(s)/PHV(s).This is not a complete solution --- it would be even better if wecould remove PHVs after reducing them to no-ops. It doesn't lookpractical to back-patch such an improvement, but this change seemssafe and at least gets rid of the performance-regression cases.Per complaint from Nikhil Raj. Back-patch to v16 where theproblem appeared.Discussion:https://postgr.es/m/CAG1ps1xvnTZceKK24OUfMKLPvDP2vjT-d+F2AOCWbw_v3KeEgg@mail.gmail.com1 parent3409b4d commitcb8e50a
File tree
4 files changed
+107
-15
lines changed- src
- backend
- optimizer/prep
- rewrite
- test/regress
- expected
- sql
4 files changed
+107
-15
lines changedLines changed: 54 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2490 | 2490 |
| |
2491 | 2491 |
| |
2492 | 2492 |
| |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2493 | 2498 |
| |
2494 | 2499 |
| |
2495 | 2500 |
| |
2496 |
| - | |
2497 |
| - | |
2498 |
| - | |
| 2501 | + | |
| 2502 | + | |
| 2503 | + | |
| 2504 | + | |
| 2505 | + | |
| 2506 | + | |
| 2507 | + | |
| 2508 | + | |
| 2509 | + | |
| 2510 | + | |
| 2511 | + | |
| 2512 | + | |
| 2513 | + | |
| 2514 | + | |
| 2515 | + | |
| 2516 | + | |
| 2517 | + | |
| 2518 | + | |
| 2519 | + | |
2499 | 2520 |
| |
2500 |
| - | |
| 2521 | + | |
| 2522 | + | |
| 2523 | + | |
| 2524 | + | |
| 2525 | + | |
| 2526 | + | |
| 2527 | + | |
| 2528 | + | |
| 2529 | + | |
| 2530 | + | |
| 2531 | + | |
| 2532 | + | |
| 2533 | + | |
| 2534 | + | |
2501 | 2535 |
| |
2502 | 2536 |
| |
2503 | 2537 |
| |
| |||
2518 | 2552 |
| |
2519 | 2553 |
| |
2520 | 2554 |
| |
2521 |
| - | |
2522 |
| - | |
2523 |
| - | |
2524 |
| - | |
2525 |
| - | |
| 2555 | + | |
2526 | 2556 |
| |
2527 | 2557 |
| |
2528 | 2558 |
| |
2529 | 2559 |
| |
2530 | 2560 |
| |
2531 | 2561 |
| |
2532 |
| - | |
| 2562 | + | |
2533 | 2563 |
| |
2534 | 2564 |
| |
2535 | 2565 |
| |
2536 | 2566 |
| |
2537 | 2567 |
| |
2538 | 2568 |
| |
2539 | 2569 |
| |
2540 |
| - | |
| 2570 | + | |
2541 | 2571 |
| |
2542 | 2572 |
| |
2543 | 2573 |
| |
2544 | 2574 |
| |
2545 |
| - | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
2546 | 2584 |
| |
2547 | 2585 |
| |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
2548 | 2590 |
| |
2549 | 2591 |
| |
2550 | 2592 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1141 | 1141 |
| |
1142 | 1142 |
| |
1143 | 1143 |
| |
1144 |
| - | |
| 1144 | + | |
| 1145 | + | |
1145 | 1146 |
| |
1146 | 1147 |
| |
1147 | 1148 |
| |
| |||
1170 | 1171 |
| |
1171 | 1172 |
| |
1172 | 1173 |
| |
1173 |
| - | |
| 1174 | + | |
| 1175 | + | |
1174 | 1176 |
| |
1175 | 1177 |
| |
1176 | 1178 |
| |
| |||
1188 | 1190 |
| |
1189 | 1191 |
| |
1190 | 1192 |
| |
1191 |
| - | |
| 1193 | + | |
| 1194 | + | |
1192 | 1195 |
| |
1193 | 1196 |
| |
1194 | 1197 |
| |
|
Lines changed: 29 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1721 | 1721 |
| |
1722 | 1722 |
| |
1723 | 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 | + | |
| 1751 | + | |
| 1752 | + | |
1724 | 1753 |
| |
1725 | 1754 |
| |
1726 | 1755 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
890 | 890 |
| |
891 | 891 |
| |
892 | 892 |
| |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
893 | 911 |
| |
894 | 912 |
| |
895 | 913 |
| |
|
0 commit comments
Comments
(0)