forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2cca95e
committed
Improve NestLoopParam generation for lateral subqueries
It was possible in cases where we had a LATERAL joined subquery thatwhen the same Var is mentioned in both the lateral references and in theouter Vars of the scan clauses that the given Var wouldn't be assignedto the same NestLoopParam.This could cause issues in Memoize as the cache key would reference theVar for the scan clauses but when the parameter for the lateral referenceschanged some code in Memoize would see that some other parameter hadchanged that's not part of the cache key and end up purging the entirecache as a result, thinking the cache had become stale. This couldresult in a Nested Loop -> Memoize plan being quite inefficient as, inthe worst case, the cache purging could result in never getting a cachehit. In no cases could this problem lead to incorrect query results.Here we switch the order of operations so that we create NestLoopParamfor the lateral references first before doing replace_nestloop_params().replace_nestloop_params() will find and reuse the existing NestLoopParamin cases where the Var exists in both locations.Author: Richard GuoReviewed-by: Tom Lane, David RowleyDiscussion:https://postgr.es/m/CAMbWs48XHJEK1Q1CzAQ7L9sTANTs9W1cepXu8%3DKc0quUL%2Btg4Q%40mail.gmail.com1 parentf2743a7 commit2cca95e
File tree
3 files changed
+66
-3
lines changed- src
- backend/optimizer/plan
- test/regress
- expected
- sql
3 files changed
+66
-3
lines changedLines changed: 12 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3720 | 3720 |
| |
3721 | 3721 |
| |
3722 | 3722 |
| |
3723 |
| - | |
| 3723 | + | |
| 3724 | + | |
| 3725 | + | |
| 3726 | + | |
| 3727 | + | |
| 3728 | + | |
| 3729 | + | |
| 3730 | + | |
| 3731 | + | |
| 3732 | + | |
3724 | 3733 |
| |
3725 | 3734 |
| |
3726 |
| - | |
3727 |
| - | |
3728 | 3735 |
| |
3729 | 3736 |
| |
| 3737 | + | |
| 3738 | + | |
3730 | 3739 |
| |
3731 | 3740 |
| |
3732 | 3741 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
95 | 132 |
| |
96 | 133 |
| |
97 | 134 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
60 | 77 |
| |
61 | 78 |
| |
62 | 79 |
| |
|
0 commit comments
Comments
(0)