- Notifications
You must be signed in to change notification settings - Fork5
Commitd222585
committed
Allow pushdown of WHERE quals into subqueries with window functions.
We can allow this even without any specific knowledge of the semanticsof the window function, so long as pushed-down quals will either acceptevery row in a given window partition, or reject every such row. Becausewindow functions act only within a partition, such a case can't resultin changing the window functions' outputs for any surviving row.Eliminating entire partitions in this way obviously can reduce the costof the window-function computations substantially.The fly in the ointment is that it's hard to be entirely sure whetherthis is true for an arbitrary qual condition. This patch allows pushdownif (a) the qual references only partitioning columns, and (b) the qualcontains no volatile functions. We are at risk of incorrect results ifthe qual can produce different answers for values that the partitioningequality operator sees as equal. While it's not hard to invent casesfor which that can happen, it seems to seldom be a problem in practice,since no one has complained about a similar assumption that we've hadfor many years with respect to DISTINCT. The potential performancegains seem to be worth the risk.David Rowley, reviewed by Vik Fearing; some credit is due also toThomas Mayer who did considerable preliminary investigation.1 parentf741300 commitd222585
File tree
3 files changed
+128
-12
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+128
-12
lines changedLines changed: 67 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
| |||
1688 | 1689 |
| |
1689 | 1690 |
| |
1690 | 1691 |
| |
1691 |
| - | |
1692 |
| - | |
1693 |
| - | |
1694 |
| - | |
| 1692 | + | |
1695 | 1693 |
| |
1696 | 1694 |
| |
1697 |
| - | |
| 1695 | + | |
1698 | 1696 |
| |
1699 | 1697 |
| |
1700 | 1698 |
| |
1701 | 1699 |
| |
1702 | 1700 |
| |
1703 | 1701 |
| |
1704 | 1702 |
| |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
1705 | 1709 |
| |
1706 | 1710 |
| |
1707 | 1711 |
| |
| |||
1723 | 1727 |
| |
1724 | 1728 |
| |
1725 | 1729 |
| |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
1726 | 1742 |
| |
1727 | 1743 |
| |
1728 | 1744 |
| |
| |||
1734 | 1750 |
| |
1735 | 1751 |
| |
1736 | 1752 |
| |
1737 |
| - | |
1738 |
| - | |
1739 |
| - | |
1740 |
| - | |
1741 |
| - | |
1742 |
| - | |
| 1753 | + | |
| 1754 | + | |
1743 | 1755 |
| |
1744 | 1756 |
| |
1745 | 1757 |
| |
| |||
1795 | 1807 |
| |
1796 | 1808 |
| |
1797 | 1809 |
| |
1798 |
| - | |
| 1810 | + | |
1799 | 1811 |
| |
1800 | 1812 |
| |
1801 | 1813 |
| |
| |||
1835 | 1847 |
| |
1836 | 1848 |
| |
1837 | 1849 |
| |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
1838 | 1859 |
| |
1839 | 1860 |
| |
1840 | 1861 |
| |
| |||
1874 | 1895 |
| |
1875 | 1896 |
| |
1876 | 1897 |
| |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
1877 | 1907 |
| |
1878 | 1908 |
| |
1879 | 1909 |
| |
| |||
1917 | 1947 |
| |
1918 | 1948 |
| |
1919 | 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 | + | |
1920 | 1975 |
| |
1921 | 1976 |
| |
1922 | 1977 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1034 | 1034 |
| |
1035 | 1035 |
| |
1036 | 1036 |
| |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
| 1065 | + | |
| 1066 | + | |
| 1067 | + | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
1037 | 1078 |
| |
1038 | 1079 |
| |
1039 | 1080 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
272 | 272 |
| |
273 | 273 |
| |
274 | 274 |
| |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
275 | 295 |
| |
276 | 296 |
| |
277 | 297 |
| |
|
0 commit comments
Comments
(0)