forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7ca25b7
committed
Fix neqjoinsel's behavior for semi/anti join cases.
Previously, this function estimated the selectivity as 1 minus eqjoinsel()for the negator equality operator, regardless of join type (I think therewas an expectation that eqjoinsel would handle the join type). Butactually this is completely wrong for semijoin cases: the fraction of theLHS that has a non-matching row is not one minus the fraction of the LHSthat has a matching row. In reality a semijoin with <> will nearly alwayssucceed: it can only fail when the RHS is empty, or it contains a singledistinct value that is equal to the particular LHS value, or the LHS valueis null. The only one of those things we should have much confidence inestimating is the fraction of LHS values that are null, so let's just takethe selectivity as 1 minus outer nullfrac.Per coding convention, antijoin should be estimated the same as semijoin.Arguably this is a bug fix, but in view of the lack of field complaintsand the risk of destabilizing plans, no back-patch.Thomas Munro, reviewed by Ashutosh BapatDiscussion:https://postgr.es/m/CAEepm=270ze2hVxWkJw-5eKzc3AB4C9KpH3L2kih75R5pdSogg@mail.gmail.com1 parent1145acc commit7ca25b7
File tree
3 files changed
+85
-16
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+85
-16
lines changedLines changed: 54 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2767 | 2767 |
| |
2768 | 2768 |
| |
2769 | 2769 |
| |
2770 |
| - | |
2771 | 2770 |
| |
2772 | 2771 |
| |
2773 |
| - | |
2774 |
| - | |
2775 |
| - | |
2776 |
| - | |
2777 |
| - | |
2778 |
| - | |
| 2772 | + | |
2779 | 2773 |
| |
2780 |
| - | |
2781 |
| - | |
2782 |
| - | |
2783 |
| - | |
2784 |
| - | |
2785 |
| - | |
| 2774 | + | |
| 2775 | + | |
| 2776 | + | |
| 2777 | + | |
| 2778 | + | |
| 2779 | + | |
| 2780 | + | |
| 2781 | + | |
| 2782 | + | |
| 2783 | + | |
| 2784 | + | |
| 2785 | + | |
| 2786 | + | |
| 2787 | + | |
| 2788 | + | |
| 2789 | + | |
| 2790 | + | |
| 2791 | + | |
| 2792 | + | |
| 2793 | + | |
| 2794 | + | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
| 2798 | + | |
| 2799 | + | |
| 2800 | + | |
| 2801 | + | |
| 2802 | + | |
| 2803 | + | |
| 2804 | + | |
2786 | 2805 |
| |
2787 | 2806 |
| |
2788 | 2807 |
| |
2789 |
| - | |
2790 |
| - | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
2791 | 2829 |
| |
2792 |
| - | |
| 2830 | + | |
2793 | 2831 |
| |
2794 | 2832 |
| |
2795 | 2833 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1845 | 1845 |
| |
1846 | 1846 |
| |
1847 | 1847 |
| |
| 1848 | + | |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
1848 | 1870 |
| |
1849 | 1871 |
| |
1850 | 1872 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
193 | 193 |
| |
194 | 194 |
| |
195 | 195 |
| |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
196 | 205 |
| |
197 | 206 |
| |
198 | 207 |
| |
|
0 commit comments
Comments
(0)