Commit d6cffd7
authored
optimizer: Add configuration to disable join reordering (#21072)
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes #123` indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
Now DataFusion has heuristics for join reordering based on plan
statistics
https://github.com/apache/datafusion/blob/9885f4bfe88ae9e4df96466d7246b80244b8054a/datafusion/physical-optimizer/src/join_selection.rs#L59
This PR adds one option to disable it. If it's set to false, join
reordering won't happen, and always be the same as the join order appear
in the query.
```sql
set datafusion.optimizer.join_reordering = false;
-- always t1 on the left, t2 on the right regardless of t1/t2 statistics
select *
from t1
join t2
on t1.v1=t2.v1;
```
The reasons are:
- Heuristics can fail, this configuration makes it possible to hand-tune
join orders
- Some tests assumes join order, if we can keep the join order fixed,
they're easier to maintain.
## What changes are included in this PR?
<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->
1. Added a configuration
2. Propagate the config into join swapping utility, and disable join
re-ordering if the config is disabled.
## Are these changes tested?
sqllogictests
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
4. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->
## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->1 parent 895d852 commit d6cffd7
5 files changed
Lines changed: 128 additions & 38 deletions
File tree
- datafusion
- common/src
- physical-optimizer/src
- sqllogictest/test_files
- docs/source/user-guide
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1088 | 1088 | | |
1089 | 1089 | | |
1090 | 1090 | | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
1091 | 1097 | | |
1092 | 1098 | | |
1093 | 1099 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
59 | 70 | | |
60 | 71 | | |
61 | 72 | | |
| 73 | + | |
62 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
63 | 79 | | |
64 | 80 | | |
65 | 81 | | |
| |||
133 | 149 | | |
134 | 150 | | |
135 | 151 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | 152 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
| |||
162 | 169 | | |
163 | 170 | | |
164 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
165 | 177 | | |
166 | 178 | | |
167 | 179 | | |
168 | | - | |
169 | | - | |
| 180 | + | |
170 | 181 | | |
171 | 182 | | |
172 | 183 | | |
| 184 | + | |
173 | 185 | | |
174 | 186 | | |
175 | 187 | | |
176 | 188 | | |
177 | | - | |
178 | | - | |
| 189 | + | |
| 190 | + | |
179 | 191 | | |
180 | 192 | | |
181 | 193 | | |
182 | 194 | | |
183 | | - | |
184 | | - | |
| 195 | + | |
| 196 | + | |
185 | 197 | | |
186 | 198 | | |
187 | 199 | | |
188 | 200 | | |
189 | 201 | | |
190 | 202 | | |
191 | 203 | | |
192 | | - | |
| 204 | + | |
193 | 205 | | |
194 | 206 | | |
195 | 207 | | |
| |||
209 | 221 | | |
210 | 222 | | |
211 | 223 | | |
212 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
213 | 228 | | |
214 | 229 | | |
215 | 230 | | |
| |||
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
227 | 245 | | |
228 | 246 | | |
| 247 | + | |
229 | 248 | | |
230 | 249 | | |
231 | 250 | | |
232 | 251 | | |
233 | 252 | | |
234 | 253 | | |
235 | | - | |
| 254 | + | |
236 | 255 | | |
237 | 256 | | |
238 | 257 | | |
| |||
256 | 275 | | |
257 | 276 | | |
258 | 277 | | |
259 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
260 | 285 | | |
261 | 286 | | |
262 | | - | |
263 | | - | |
| 287 | + | |
264 | 288 | | |
265 | 289 | | |
266 | 290 | | |
267 | 291 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
279 | 298 | | |
280 | | - | |
| 299 | + | |
281 | 300 | | |
282 | 301 | | |
283 | 302 | | |
| |||
286 | 305 | | |
287 | 306 | | |
288 | 307 | | |
289 | | - | |
| 308 | + | |
290 | 309 | | |
291 | 310 | | |
292 | 311 | | |
| |||
299 | 318 | | |
300 | 319 | | |
301 | 320 | | |
302 | | - | |
| 321 | + | |
303 | 322 | | |
304 | 323 | | |
305 | 324 | | |
| |||
308 | 327 | | |
309 | 328 | | |
310 | 329 | | |
311 | | - | |
| 330 | + | |
312 | 331 | | |
313 | 332 | | |
314 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| 315 | + | |
315 | 316 | | |
316 | 317 | | |
317 | 318 | | |
| |||
452 | 453 | | |
453 | 454 | | |
454 | 455 | | |
| 456 | + | |
455 | 457 | | |
456 | 458 | | |
457 | 459 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1596 | 1596 | | |
1597 | 1597 | | |
1598 | 1598 | | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
| 1613 | + | |
| 1614 | + | |
| 1615 | + | |
| 1616 | + | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
| 1627 | + | |
| 1628 | + | |
| 1629 | + | |
1599 | 1630 | | |
1600 | 1631 | | |
1601 | 1632 | | |
| |||
2053 | 2084 | | |
2054 | 2085 | | |
2055 | 2086 | | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
2056 | 2118 | | |
2057 | 2119 | | |
2058 | 2120 | | |
| |||
0 commit comments