- Notifications
You must be signed in to change notification settings - Fork5
Commit66a7e6b
committed
Improve estimation of IN/NOT IN by assuming array elements are distinct.
In constructs such as "x IN (1,2,3,4)" and "x <> ALL(ARRAY[1,2,3,4])",we formerly always used a general-purpose assumption that the probabilityof success is independent for each comparison of "x" to an array element.But in real-world usage of these constructs, that's a pretty poorassumption; it's much saner to assume that the array elements are distinctand so the match probabilities are disjoint. Apply that assumption if theoperator appears to behave as equality (for ANY) or inequality (for ALL).But fall back to the normal independent-probabilities calculation if thisyields an impossible result, ie probability > 1 or < 0. We could protectourselves against bad estimates even more by explicitly checking for equalarray elements, but that is expensive and doesn't seem worthwhile: doingit would amount to optimizing for poorly-written queries at the expenseof well-written ones.Daniele Varrazzo and Tom Lane, after a suggestion by Ants Aasma1 parent1ed7f0e commit66a7e6b
1 file changed
+71
-3
lines changedLines changed: 71 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1712 | 1712 |
| |
1713 | 1713 |
| |
1714 | 1714 |
| |
| 1715 | + | |
1715 | 1716 |
| |
1716 | 1717 |
| |
1717 | 1718 |
| |
| |||
1768 | 1769 |
| |
1769 | 1770 |
| |
1770 | 1771 |
| |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
| 1775 | + | |
| 1776 | + | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + | |
| 1780 | + | |
| 1781 | + | |
| 1782 | + | |
| 1783 | + | |
| 1784 | + | |
1771 | 1785 |
| |
1772 | 1786 |
| |
1773 | 1787 |
| |
| |||
1802 | 1816 |
| |
1803 | 1817 |
| |
1804 | 1818 |
| |
1805 |
| - | |
| 1819 | + | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
| 1834 | + | |
| 1835 | + | |
1806 | 1836 |
| |
1807 | 1837 |
| |
1808 | 1838 |
| |
| |||
1829 | 1859 |
| |
1830 | 1860 |
| |
1831 | 1861 |
| |
| 1862 | + | |
1832 | 1863 |
| |
| 1864 | + | |
1833 | 1865 |
| |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
1834 | 1869 |
| |
| 1870 | + | |
1835 | 1871 |
| |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
1836 | 1875 |
| |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
1837 | 1881 |
| |
1838 | 1882 |
| |
1839 | 1883 |
| |
| |||
1845 | 1889 |
| |
1846 | 1890 |
| |
1847 | 1891 |
| |
1848 |
| - | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
1849 | 1902 |
| |
1850 | 1903 |
| |
1851 | 1904 |
| |
| |||
1871 | 1924 |
| |
1872 | 1925 |
| |
1873 | 1926 |
| |
| 1927 | + | |
1874 | 1928 |
| |
| 1929 | + | |
1875 | 1930 |
| |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1876 | 1934 |
| |
| 1935 | + | |
1877 | 1936 |
| |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
1878 | 1940 |
| |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
| 1945 | + | |
1879 | 1946 |
| |
1880 | 1947 |
| |
1881 | 1948 |
| |
| |||
1911 | 1978 |
| |
1912 | 1979 |
| |
1913 | 1980 |
| |
1914 |
| - | |
| 1981 | + | |
| 1982 | + | |
1915 | 1983 |
| |
1916 | 1984 |
| |
1917 | 1985 |
| |
|
0 commit comments
Comments
(0)