forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita65724d
committed
Propagate pathkeys from CTEs up to the outer query.
If we know the sort order of a CTE's output, and it is relevantto the outer query, label the CTE's outer-query access path usingthose pathkeys. This may enable optimizations such as avoidinga sort in the outer query.The code for hoisting pathkeys into the outer query already existsfor regular RTE_SUBQUERY subqueries, but it wasn't getting used forCTEs, possibly out of concern for maintaining an optimization fencebetween the CTE and the outer query. However, on the same argumentsused for commitf7816ae, there seems no harm in letting the outerquery know what the inner query decided to do.In support of this, we now remember the best Path as well as Planfor each subquery for the rest of the planner run. There may befuture applications for having that at hand, and it surely costslittle to build one more List.Richard Guo (minor mods by me)Discussion:https://postgr.es/m/CAMbWs49xYd3f8CrE8-WW3--dV1zH_sDSDn-vs2DzHj81Wcnsew@mail.gmail.com1 parente648e77 commita65724d
File tree
8 files changed
+64
-15
lines changed- src
- backend/optimizer
- path
- plan
- util
- include
- nodes
- optimizer
- test/regress
- expected
- sql
8 files changed
+64
-15
lines changedLines changed: 14 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2872 | 2872 |
| |
2873 | 2873 |
| |
2874 | 2874 |
| |
| 2875 | + | |
2875 | 2876 |
| |
2876 | 2877 |
| |
2877 | 2878 |
| |
| 2879 | + | |
2878 | 2880 |
| |
2879 | 2881 |
| |
2880 | 2882 |
| |
2881 | 2883 |
| |
2882 | 2884 |
| |
2883 | 2885 |
| |
2884 |
| - | |
| 2886 | + | |
| 2887 | + | |
2885 | 2888 |
| |
2886 | 2889 |
| |
2887 | 2890 |
| |
| |||
2913 | 2916 |
| |
2914 | 2917 |
| |
2915 | 2918 |
| |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
2916 | 2922 |
| |
2917 | 2923 |
| |
2918 | 2924 |
| |
2919 | 2925 |
| |
2920 | 2926 |
| |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
2921 | 2933 |
| |
2922 | 2934 |
| |
2923 | 2935 |
| |
| |||
2926 | 2938 |
| |
2927 | 2939 |
| |
2928 | 2940 |
| |
2929 |
| - | |
| 2941 | + | |
2930 | 2942 |
| |
2931 | 2943 |
| |
2932 | 2944 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
306 | 306 |
| |
307 | 307 |
| |
308 | 308 |
| |
| 309 | + | |
309 | 310 |
| |
310 | 311 |
| |
311 | 312 |
| |
|
Lines changed: 18 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
68 |
| - | |
69 |
| - | |
| 68 | + | |
| 69 | + | |
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| |||
236 | 236 |
| |
237 | 237 |
| |
238 | 238 |
| |
239 |
| - | |
| 239 | + | |
| 240 | + | |
240 | 241 |
| |
241 | 242 |
| |
242 | 243 |
| |
| |||
288 | 289 |
| |
289 | 290 |
| |
290 | 291 |
| |
291 |
| - | |
292 |
| - | |
| 292 | + | |
| 293 | + | |
293 | 294 |
| |
294 | 295 |
| |
295 | 296 |
| |
| |||
317 | 318 |
| |
318 | 319 |
| |
319 | 320 |
| |
320 |
| - | |
321 |
| - | |
| 321 | + | |
| 322 | + | |
322 | 323 |
| |
323 | 324 |
| |
324 | 325 |
| |
| |||
539 | 540 |
| |
540 | 541 |
| |
541 | 542 |
| |
542 |
| - | |
| 543 | + | |
543 | 544 |
| |
544 | 545 |
| |
| 546 | + | |
545 | 547 |
| |
546 | 548 |
| |
547 | 549 |
| |
| |||
1029 | 1031 |
| |
1030 | 1032 |
| |
1031 | 1033 |
| |
1032 |
| - | |
| 1034 | + | |
1033 | 1035 |
| |
1034 | 1036 |
| |
| 1037 | + | |
1035 | 1038 |
| |
1036 | 1039 |
| |
1037 | 1040 |
| |
| |||
3021 | 3024 |
| |
3022 | 3025 |
| |
3023 | 3026 |
| |
3024 |
| - | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
3025 | 3032 |
| |
3026 | 3033 |
| |
| 3034 | + | |
3027 | 3035 |
| |
3028 | 3036 |
| |
3029 | 3037 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2121 | 2121 |
| |
2122 | 2122 |
| |
2123 | 2123 |
| |
2124 |
| - | |
| 2124 | + | |
| 2125 | + | |
2125 | 2126 |
| |
2126 | 2127 |
| |
2127 | 2128 |
| |
| |||
2133 | 2134 |
| |
2134 | 2135 |
| |
2135 | 2136 |
| |
2136 |
| - | |
| 2137 | + | |
2137 | 2138 |
| |
2138 | 2139 |
| |
2139 | 2140 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
| 107 | + | |
| 108 | + | |
| 109 | + | |
107 | 110 |
| |
108 | 111 |
| |
109 | 112 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
115 | 115 |
| |
116 | 116 |
| |
117 | 117 |
| |
118 |
| - | |
| 118 | + | |
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
672 | 672 |
| |
673 | 673 |
| |
674 | 674 |
| |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
675 | 692 |
| |
676 | 693 |
| |
677 | 694 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
359 | 359 |
| |
360 | 360 |
| |
361 | 361 |
| |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
362 | 369 |
| |
363 | 370 |
| |
364 | 371 |
| |
|
0 commit comments
Comments
(0)