forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7b6c075
committed
Teach planner to account for HAVING quals in aggregation plan nodes.
For some reason, we have never accounted for either the evaluation costor the selectivity of filter conditions attached to Agg and Group nodes(which, in practice, are always conditions from a HAVING clause).Applying our regular selectivity logic to post-grouping conditions is abit bogus, but it's surely better than taking the selectivity as 1.0.Perhaps someday the extended-statistics mechanism can be taught to providestatistics that would help us in getting non-default estimates here.Per a gripe from Benjamin Coutu. This is surely a bug fix, but I'mhesitant to back-patch because of the prospect of destabilizing existingplan choices. Given that it took us this long to notice the bug, it'sprobably not hurting too many people in the field.Discussion:https://postgr.es/m/20968.1509486337@sss.pgh.pa.us1 parentc6764eb commit7b6c075
File tree
4 files changed
+74
-1
lines changed- src
- backend/optimizer
- path
- prep
- util
- include/optimizer
4 files changed
+74
-1
lines changedLines changed: 45 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1874 | 1874 |
| |
1875 | 1875 |
| |
1876 | 1876 |
| |
| 1877 | + | |
1877 | 1878 |
| |
1878 | 1879 |
| |
1879 | 1880 |
| |
| |||
1955 | 1956 |
| |
1956 | 1957 |
| |
1957 | 1958 |
| |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
| 1964 | + | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
1958 | 1979 |
| |
1959 | 1980 |
| |
1960 | 1981 |
| |
| |||
2040 | 2061 |
| |
2041 | 2062 |
| |
2042 | 2063 |
| |
| 2064 | + | |
2043 | 2065 |
| |
2044 | 2066 |
| |
2045 | 2067 |
| |
| 2068 | + | |
2046 | 2069 |
| |
2047 | 2070 |
| |
2048 | 2071 |
| |
| 2072 | + | |
2049 | 2073 |
| |
2050 | 2074 |
| |
2051 | 2075 |
| |
| |||
2055 | 2079 |
| |
2056 | 2080 |
| |
2057 | 2081 |
| |
2058 |
| - | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
2059 | 2103 |
| |
2060 | 2104 |
| |
2061 | 2105 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
977 | 977 |
| |
978 | 978 |
| |
979 | 979 |
| |
| 980 | + | |
980 | 981 |
| |
981 | 982 |
| |
982 | 983 |
| |
| |||
991 | 992 |
| |
992 | 993 |
| |
993 | 994 |
| |
| 995 | + | |
994 | 996 |
| |
995 | 997 |
| |
996 | 998 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1374 | 1374 |
| |
1375 | 1375 |
| |
1376 | 1376 |
| |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
1377 | 1382 |
| |
1378 | 1383 |
| |
1379 | 1384 |
| |
| |||
1596 | 1601 |
| |
1597 | 1602 |
| |
1598 | 1603 |
| |
| 1604 | + | |
1599 | 1605 |
| |
1600 | 1606 |
| |
1601 | 1607 |
| |
| |||
2592 | 2598 |
| |
2593 | 2599 |
| |
2594 | 2600 |
| |
| 2601 | + | |
2595 | 2602 |
| |
2596 | 2603 |
| |
2597 | 2604 |
| |
| |||
2709 | 2716 |
| |
2710 | 2717 |
| |
2711 | 2718 |
| |
| 2719 | + | |
2712 | 2720 |
| |
2713 | 2721 |
| |
2714 | 2722 |
| |
| |||
2817 | 2825 |
| |
2818 | 2826 |
| |
2819 | 2827 |
| |
| 2828 | + | |
2820 | 2829 |
| |
2821 | 2830 |
| |
2822 | 2831 |
| |
| |||
2840 | 2849 |
| |
2841 | 2850 |
| |
2842 | 2851 |
| |
| 2852 | + | |
2843 | 2853 |
| |
2844 | 2854 |
| |
2845 | 2855 |
| |
| |||
2863 | 2873 |
| |
2864 | 2874 |
| |
2865 | 2875 |
| |
| 2876 | + | |
2866 | 2877 |
| |
2867 | 2878 |
| |
2868 | 2879 |
| |
| |||
2932 | 2943 |
| |
2933 | 2944 |
| |
2934 | 2945 |
| |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
2935 | 2959 |
| |
2936 | 2960 |
| |
2937 | 2961 |
| |
| |||
3781 | 3805 |
| |
3782 | 3806 |
| |
3783 | 3807 |
| |
| 3808 | + | |
3784 | 3809 |
| |
3785 | 3810 |
| |
3786 | 3811 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
| 119 | + | |
119 | 120 |
| |
120 | 121 |
| |
121 | 122 |
| |
| |||
124 | 125 |
| |
125 | 126 |
| |
126 | 127 |
| |
| 128 | + | |
127 | 129 |
| |
128 | 130 |
| |
129 | 131 |
| |
|
0 commit comments
Comments
(0)