forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6bef118
committed
Restructure code that is responsible for ensuring that clauseless joins are
considered when it is necessary to do so because of a join-order restriction(that is, an outer-join or IN-subselect construct). The former coding was abit ad-hoc and inconsistent, and it missed some cases, as exposed by MarioWeilguni's recent bug report. His specific problem was that an IN could beturned into a "clauseless" join due to constant-propagation removing the IN'sjoinclause, and if the IN's subselect involved more than one relation andthere was more than one such IN linking to the same upper relation, then theonly valid join orders involve "bushy" plans but we would fail to consider thespecific paths needed to get there. (See the example case added to the joinregression test.) On examining the code I wonder if there weren't some otherproblem cases too; in particular it seems that GEQO was defending against adifferent set of corner cases than the main planner was. There was also anefficiency problem, in that when we did realize we needed a clauseless joinbecause of an IN, we'd consider clauseless joins against every other relationwhether this was sensible or not. It seems a better design is to use theouter-join and in-clause lists as a backup heuristic, just as the rule ofjoining only where there are joinclauses is a heuristic: we'll join tworelations if they have a usable joinclause *or* this might be necessary tosatisfy an outer-join or IN-clause join order restriction. I refactored thecode to have just one place considering this instead of three, and made surethat it covered all the cases that any of them had been considering.Backpatch as far as 8.1 (which has only the IN-clause form of the disease).By rights 8.0 and 7.4 should have the bug too, but they accidentally failto fail, because the joininfo structure used in those releases preserves somememory of there having once been a joinclause between the inner and outersides of an IN, and so it leads the code in the right direction anyway.I'll be conservative and not touch them.1 parent1820650 commit6bef118
File tree
8 files changed
+223
-151
lines changed- src
- backend/optimizer
- geqo
- path
- util
- include/optimizer
- test/regress
- expected
- sql
8 files changed
+223
-151
lines changedLines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
105 | 105 |
| |
106 | 106 |
| |
107 | 107 |
| |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
114 | 118 |
| |
115 | 119 |
| |
116 | 120 |
| |
|
Lines changed: 5 additions & 43 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
6 | 6 |
| |
7 | 7 |
| |
8 | 8 |
| |
9 |
| - | |
| 9 | + | |
10 | 10 |
| |
11 | 11 |
| |
12 | 12 |
| |
| |||
253 | 253 |
| |
254 | 254 |
| |
255 | 255 |
| |
256 |
| - | |
257 |
| - | |
258 | 256 |
| |
259 |
| - | |
| 257 | + | |
| 258 | + | |
260 | 259 |
| |
261 |
| - | |
| 260 | + | |
| 261 | + | |
262 | 262 |
| |
263 | 263 |
| |
264 |
| - | |
265 |
| - | |
266 |
| - | |
267 |
| - | |
268 |
| - | |
269 |
| - | |
270 |
| - | |
271 |
| - | |
272 |
| - | |
273 |
| - | |
274 |
| - | |
275 |
| - | |
276 |
| - | |
277 |
| - | |
278 |
| - | |
279 |
| - | |
280 |
| - | |
281 |
| - | |
282 |
| - | |
283 |
| - | |
284 |
| - | |
285 |
| - | |
286 |
| - | |
287 |
| - | |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 |
| - | |
292 |
| - | |
293 |
| - | |
294 |
| - | |
295 |
| - | |
296 |
| - | |
297 |
| - | |
298 |
| - | |
299 |
| - | |
300 |
| - | |
301 |
| - | |
302 | 264 |
| |
303 | 265 |
| |
304 | 266 |
|
0 commit comments
Comments
(0)