forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3fc6e2d
committed
Make the upper part of the planner work by generating and comparing Paths.
I've been saying we needed to do this for more than five years, and here itfinally is. This patch removes the ever-growing tangle of spaghetti logicthat grouping_planner() used to use to try to identify the best plan forpost-scan/join query steps. Now, there is (nearly) independentconsideration of each execution step, and entirely separate construction ofPaths to represent each of the possible ways to do that step. We choosethe best Path or set of Paths using the same add_path() logic that's beenused inside query_planner() for years.In addition, this patch removes the old restriction that subquery_planner()could return only a single Plan. It now returns a RelOptInfo containing aset of Paths, just as query_planner() does, and the parent query level canuse each of those Paths as the basis of a SubqueryScanPath at its level.This allows finding some optimizations that we missed before, wherein asubquery was capable of returning presorted data and thereby avoiding asort in the parent level, making the overall cost cheaper even thoughdelivering sorted output was not the cheapest plan for the subquery inisolation. (A couple of regression test outputs change in consequence ofthat. However, there is very little change in visible planner behavioroverall, because the point of this patch is not to get immediate planningbenefits but to create the infrastructure for future improvements.)There is a great deal left to do here. This patch unblocks a lot ofplanner work that was basically impractical in the old code structure,such as allowing FDWs to implement remote aggregation, or rewritingplan_set_operations() to allow consideration of multiple implementationorders for set operations. (The latter will likely require a fullrewrite of plan_set_operations(); what I've done here is only to fix itto return Paths not Plans.) I have also left unfinished some localizedrefactoring in createplan.c and planner.c, because it was not necessaryto get this patch to a working state.Thanks to Robert Haas, David Rowley, and Amit Kapila for review.1 parentb642e50 commit3fc6e2d
File tree
35 files changed
+5573
-3108
lines changed- doc/src/sgml
- src
- backend
- executor
- nodes
- optimizer
- path
- plan
- prep
- util
- include
- nodes
- optimizer
- test/regress/expected
35 files changed
+5573
-3108
lines changedLines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1316 | 1316 |
| |
1317 | 1317 |
| |
1318 | 1318 |
| |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
1319 | 1353 |
| |
1320 | 1354 |
| |
1321 | 1355 |
| |
|
Lines changed: 13 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
411 |
| - | |
412 |
| - | |
413 |
| - | |
414 |
| - | |
415 |
| - | |
416 |
| - | |
417 |
| - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
418 | 414 |
| |
419 |
| - | |
420 |
| - | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
421 | 424 |
| |
422 | 425 |
| |
423 | 426 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
867 | 867 |
| |
868 | 868 |
| |
869 | 869 |
| |
870 |
| - | |
871 | 870 |
| |
872 | 871 |
| |
| 872 | + | |
873 | 873 |
| |
874 | 874 |
| |
875 | 875 |
| |
|
Lines changed: 233 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
706 | 706 |
| |
707 | 707 |
| |
708 | 708 |
| |
| 709 | + | |
| 710 | + | |
709 | 711 |
| |
710 | 712 |
| |
711 | 713 |
| |
712 | 714 |
| |
713 | 715 |
| |
714 | 716 |
| |
715 |
| - | |
716 |
| - | |
717 |
| - | |
718 | 717 |
| |
719 | 718 |
| |
720 | 719 |
| |
721 | 720 |
| |
722 | 721 |
| |
723 |
| - | |
724 | 722 |
| |
725 | 723 |
| |
726 | 724 |
| |
| |||
1603 | 1601 |
| |
1604 | 1602 |
| |
1605 | 1603 |
| |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + | |
| 1612 | + | |
1606 | 1613 |
| |
1607 | 1614 |
| |
1608 | 1615 |
| |
| |||
1703 | 1710 |
| |
1704 | 1711 |
| |
1705 | 1712 |
| |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
1706 | 1723 |
| |
1707 | 1724 |
| |
1708 | 1725 |
| |
| |||
1793 | 1810 |
| |
1794 | 1811 |
| |
1795 | 1812 |
| |
| 1813 | + | |
| 1814 | + | |
| 1815 | + | |
| 1816 | + | |
| 1817 | + | |
| 1818 | + | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
| 1838 | + | |
| 1839 | + | |
| 1840 | + | |
| 1841 | + | |
| 1842 | + | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
| 1846 | + | |
| 1847 | + | |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
| 1946 | + | |
| 1947 | + | |
| 1948 | + | |
| 1949 | + | |
| 1950 | + | |
| 1951 | + | |
| 1952 | + | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
1796 | 1981 |
| |
1797 | 1982 |
| |
1798 | 1983 |
| |
| |||
1881 | 2066 |
| |
1882 | 2067 |
| |
1883 | 2068 |
| |
| 2069 | + | |
1884 | 2070 |
| |
1885 | 2071 |
| |
1886 | 2072 |
| |
| |||
1910 | 2096 |
| |
1911 | 2097 |
| |
1912 | 2098 |
| |
| 2099 | + | |
1913 | 2100 |
| |
1914 | 2101 |
| |
1915 | 2102 |
| |
| |||
1933 | 2120 |
| |
1934 | 2121 |
| |
1935 | 2122 |
| |
1936 |
| - | |
1937 | 2123 |
| |
1938 | 2124 |
| |
1939 | 2125 |
| |
| |||
3331 | 3517 |
| |
3332 | 3518 |
| |
3333 | 3519 |
| |
| 3520 | + | |
| 3521 | + | |
| 3522 | + | |
3334 | 3523 |
| |
3335 | 3524 |
| |
3336 | 3525 |
| |
| |||
3355 | 3544 |
| |
3356 | 3545 |
| |
3357 | 3546 |
| |
| 3547 | + | |
| 3548 | + | |
| 3549 | + | |
| 3550 | + | |
| 3551 | + | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
| 3556 | + | |
| 3557 | + | |
| 3558 | + | |
| 3559 | + | |
| 3560 | + | |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
3358 | 3586 |
| |
3359 | 3587 |
| |
3360 | 3588 |
| |
|
0 commit comments
Comments
(0)