- Notifications
You must be signed in to change notification settings - Fork5
Commit8b9d323
committed
Refactor planning of projection steps that don't need a Result plan node.
The original upper-planner-pathification design (commit3fc6e2d)assumed that we could always determine during Path formation whether or notwe would need a Result plan node to perform projection of a targetlist.That turns out not to work very well, though, because createplan.c stillhas some responsibilities for choosing the specific target list associatedwith sorting/grouping nodes (in particular it might choose to add resjunkcolumns for sorting). We might not ever refactor that --- doing so wouldpush more work into Path formation, which isn't attractive --- and wecertainly won't do so for 9.6. So, while create_projection_path andapply_projection_to_path can tell for sure what will happen if the subpathis projection-capable, they can't tell for sure when it isn't. This is atleast a latent bug in apply_projection_to_path, which might think it canapply a target to a non-projecting node when the node will end up computingsomething different.Also, I'd tied the creation of a ProjectionPath node to whether or not aResult is needed, but it turns out that we sometimes need a ProjectionPathnode anyway to avoid modifying a possibly-shared subpath node. Callers hadto use create_projection_path for such cases, and we added code to themthat knew about the potential omission of a Result node and attempted toadjust the cost estimates for that. That was uncertainly correct anddefinitely ugly/unmaintainable.To fix, have create_projection_path explicitly check whether a Resultis needed and adjust its cost estimate accordingly, though it createsa ProjectionPath in either case. apply_projection_to_path is now mostlyjust an optimized version that can avoid creating an extra Path node whenthe input is known to not be shared with any other live path. (Thereis one case that create_projection_path doesn't handle, which is pushingparallel-safe expressions below a Gather node. We could make it do thatby duplicating the GatherPath, but there seems no need as yet.)create_projection_plan still has to recheck the tlist-match condition,which means that if the matching situation does get changed by createplan.cthen we'll have made a slightly incorrect cost estimate. But there seemsno help for that in the near term, and I doubt it occurs often enough,let alone would change planning decisions often enough, to be worthstressing about.I added a "dummypp" field to ProjectionPath to track whethercreate_projection_path thinks a Result is needed. This is not reallynecessary as-committed because create_projection_plan doesn't look at theflag; but it seems like a good idea to remember what we thought whenforming the cost estimate, if only for debugging purposes.In passing, get rid of the target_parallel parameter added toapply_projection_to_path by commit54f5c51. I don't think that's a goodidea because it involves callers in what should be an internal decision,and opens us up to missing optimization opportunities if callers think theydon't need to provide a valid flag, as most don't. For the moment, thisjust costs us an extra has_parallel_hazard call when planning a Gather.If that starts to look expensive, I think a better solution would be toteach PathTarget to carry/cache knowledge of parallel-safety of itscontents.1 parent936b62d commit8b9d323
File tree
8 files changed
+110
-101
lines changed- src
- backend
- nodes
- optimizer
- plan
- prep
- util
- include
- nodes
- optimizer
8 files changed
+110
-101
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1809 | 1809 |
| |
1810 | 1810 |
| |
1811 | 1811 |
| |
| 1812 | + | |
1812 | 1813 |
| |
1813 | 1814 |
| |
1814 | 1815 |
| |
|
Lines changed: 21 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1409 | 1409 |
| |
1410 | 1410 |
| |
1411 | 1411 |
| |
1412 |
| - | |
1413 |
| - | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
1414 | 1415 |
| |
1415 | 1416 |
| |
1416 | 1417 |
| |
| |||
1425 | 1426 |
| |
1426 | 1427 |
| |
1427 | 1428 |
| |
1428 |
| - | |
1429 |
| - | |
1430 |
| - | |
1431 |
| - | |
1432 |
| - | |
1433 |
| - | |
1434 |
| - | |
1435 |
| - | |
1436 |
| - | |
1437 |
| - | |
1438 |
| - | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
1439 | 1442 |
| |
1440 | 1443 |
| |
1441 | 1444 |
| |
1442 | 1445 |
| |
| 1446 | + | |
1443 | 1447 |
| |
1444 | 1448 |
| |
1445 | 1449 |
| |
1446 |
| - | |
| 1450 | + | |
1447 | 1451 |
| |
1448 | 1452 |
| |
| 1453 | + | |
| 1454 | + | |
1449 | 1455 |
| |
1450 | 1456 |
| |
1451 | 1457 |
| |
1452 | 1458 |
| |
| 1459 | + | |
1453 | 1460 |
| |
1454 | 1461 |
| |
1455 | 1462 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
465 | 465 |
| |
466 | 466 |
| |
467 | 467 |
| |
468 |
| - | |
469 |
| - | |
| 468 | + | |
470 | 469 |
| |
471 | 470 |
| |
472 | 471 |
| |
|
Lines changed: 10 additions & 44 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1500 | 1500 |
| |
1501 | 1501 |
| |
1502 | 1502 |
| |
1503 |
| - | |
1504 | 1503 |
| |
1505 | 1504 |
| |
1506 | 1505 |
| |
| |||
1730 | 1729 |
| |
1731 | 1730 |
| |
1732 | 1731 |
| |
1733 |
| - | |
1734 |
| - | |
1735 |
| - | |
1736 |
| - | |
1737 |
| - | |
1738 |
| - | |
1739 |
| - | |
1740 |
| - | |
1741 | 1732 |
| |
1742 | 1733 |
| |
1743 | 1734 |
| |
| |||
1756 | 1747 |
| |
1757 | 1748 |
| |
1758 | 1749 |
| |
1759 |
| - | |
1760 |
| - | |
| 1750 | + | |
1761 | 1751 |
| |
1762 | 1752 |
| |
1763 | 1753 |
| |
| |||
1774 | 1764 |
| |
1775 | 1765 |
| |
1776 | 1766 |
| |
1777 |
| - | |
| 1767 | + | |
| 1768 | + | |
1778 | 1769 |
| |
1779 |
| - | |
| 1770 | + | |
| 1771 | + | |
1780 | 1772 |
| |
1781 |
| - | |
1782 |
| - | |
1783 |
| - | |
1784 |
| - | |
1785 |
| - | |
| 1773 | + | |
1786 | 1774 |
| |
1787 | 1775 |
| |
1788 | 1776 |
| |
| |||
1792 | 1780 |
| |
1793 | 1781 |
| |
1794 | 1782 |
| |
1795 |
| - | |
1796 |
| - | |
1797 |
| - | |
1798 |
| - | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
1799 | 1786 |
| |
1800 | 1787 |
| |
1801 | 1788 |
| |
1802 | 1789 |
| |
1803 | 1790 |
| |
1804 |
| - | |
1805 |
| - | |
1806 |
| - | |
1807 |
| - | |
1808 |
| - | |
1809 |
| - | |
1810 |
| - | |
1811 |
| - | |
1812 |
| - | |
1813 |
| - | |
1814 |
| - | |
1815 |
| - | |
1816 |
| - | |
1817 |
| - | |
1818 |
| - | |
1819 |
| - | |
1820 |
| - | |
1821 |
| - | |
1822 |
| - | |
1823 |
| - | |
1824 |
| - | |
1825 | 1791 |
| |
1826 | 1792 |
| |
1827 | 1793 |
| |
| |||
4231 | 4197 |
| |
4232 | 4198 |
| |
4233 | 4199 |
| |
4234 |
| - | |
| 4200 | + | |
4235 | 4201 |
| |
4236 | 4202 |
| |
4237 | 4203 |
| |
|
Lines changed: 2 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
325 | 325 |
| |
326 | 326 |
| |
327 | 327 |
| |
328 |
| - | |
329 |
| - | |
| 328 | + | |
330 | 329 |
| |
331 | 330 |
| |
332 | 331 |
| |
| |||
395 | 394 |
| |
396 | 395 |
| |
397 | 396 |
| |
398 |
| - | |
399 |
| - | |
| 397 | + | |
400 | 398 |
| |
401 | 399 |
| |
402 | 400 |
| |
|
Lines changed: 63 additions & 31 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2168 | 2168 |
| |
2169 | 2169 |
| |
2170 | 2170 |
| |
| 2171 | + | |
2171 | 2172 |
| |
2172 | 2173 |
| |
2173 | 2174 |
| |
| |||
2184 | 2185 |
| |
2185 | 2186 |
| |
2186 | 2187 |
| |
2187 |
| - | |
2188 |
| - | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
2189 | 2195 |
| |
2190 |
| - | |
2191 |
| - | |
2192 |
| - | |
2193 |
| - | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
| 2202 | + | |
| 2203 | + | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
| 2209 | + | |
| 2210 | + | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
| 2219 | + | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
2194 | 2228 |
| |
2195 | 2229 |
| |
2196 | 2230 |
| |
| |||
2199 | 2233 |
| |
2200 | 2234 |
| |
2201 | 2235 |
| |
2202 |
| - | |
2203 |
| - | |
2204 |
| - | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
2205 | 2241 |
| |
2206 |
| - | |
2207 |
| - | |
2208 |
| - | |
2209 |
| - | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
2210 | 2245 |
| |
2211 |
| - | |
2212 |
| - | |
2213 |
| - | |
| 2246 | + | |
2214 | 2247 |
| |
2215 | 2248 |
| |
2216 | 2249 |
| |
2217 | 2250 |
| |
2218 | 2251 |
| |
2219 | 2252 |
| |
2220 |
| - | |
2221 | 2253 |
| |
2222 | 2254 |
| |
2223 | 2255 |
| |
2224 | 2256 |
| |
2225 | 2257 |
| |
2226 |
| - | |
2227 |
| - | |
| 2258 | + | |
2228 | 2259 |
| |
2229 | 2260 |
| |
2230 | 2261 |
| |
2231 |
| - | |
2232 |
| - | |
2233 |
| - | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
2234 | 2267 |
| |
2235 | 2268 |
| |
2236 | 2269 |
| |
| |||
2247 | 2280 |
| |
2248 | 2281 |
| |
2249 | 2282 |
| |
2250 |
| - | |
| 2283 | + | |
2251 | 2284 |
| |
2252 | 2285 |
| |
2253 |
| - | |
| 2286 | + | |
| 2287 | + | |
2254 | 2288 |
| |
2255 | 2289 |
| |
2256 | 2290 |
| |
2257 | 2291 |
| |
2258 | 2292 |
| |
2259 | 2293 |
| |
2260 | 2294 |
| |
2261 |
| - | |
2262 |
| - | |
2263 |
| - | |
2264 |
| - | |
2265 |
| - | |
| 2295 | + | |
| 2296 | + | |
| 2297 | + | |
| 2298 | + | |
| 2299 | + | |
2266 | 2300 |
| |
2267 |
| - | |
2268 |
| - | |
2269 | 2301 |
| |
2270 | 2302 |
| |
2271 | 2303 |
| |
|
Lines changed: 11 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1274 | 1274 |
| |
1275 | 1275 |
| |
1276 | 1276 |
| |
1277 |
| - | |
1278 |
| - | |
1279 |
| - | |
1280 |
| - | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1281 | 1287 |
| |
1282 | 1288 |
| |
1283 | 1289 |
| |
1284 | 1290 |
| |
1285 | 1291 |
| |
| 1292 | + | |
1286 | 1293 |
| |
1287 | 1294 |
| |
1288 | 1295 |
| |
|
Lines changed: 1 addition & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
143 | 143 |
| |
144 | 144 |
| |
145 | 145 |
| |
146 |
| - | |
147 |
| - | |
| 146 | + | |
148 | 147 |
| |
149 | 148 |
| |
150 | 149 |
| |
|
0 commit comments
Comments
(0)