forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9b282a9

Richard Guo
Fix partitionwise join with partially-redundant join clauses
To determine if the two relations being joined can use partitionwisejoin, we need to verify the existence of equi-join conditionsinvolving pairs of matching partition keys for all partition keys.Currently we do that by looking through the join's restrictionclauses. However, it has been discovered that this approach isinsufficient, because there might be partition keys known equal by aspecific EC, but they do not form a join clause because it happensthat other members of the EC than the partition keys are constrainedto become a join clause.To address this issue, in addition to examining the join's restrictionclauses, we also check if any partition keys are known equal by ECs,by leveraging function exprs_known_equal(). To accomplish this, weenhance exprs_known_equal() to check equality per the semantics of theopfamily, if provided.It could be argued that exprs_known_equal() could be called O(N^2)times, where N is the number of partition key expressions, resultingin noticeable performance costs if there are a lot of partition keyexpressions. But I think this is not a problem. The number of ajoinrel's partition key expressions would only be equal to the joindegree, since each base relation within the join contributes only onepartition key expression. That is to say, it does not scale with thenumber of partitions. A benchmark with a query involving 5-way joinsof partitioned tables, each with 3 partition keys and 1000 partitions,shows that the planning time is not significantly affected by thispatch (within the margin of error), particularly when compared to theimpact caused by partitionwise join.Thanks to Tom Lane for the idea of leveraging exprs_known_equal() tocheck if partition keys are known equal by ECs.Author: Richard Guo, Tom LaneReviewed-by: Tom Lane, Ashutosh Bapat, Robert HaasDiscussion:https://postgr.es/m/CAN_9JTzo_2F5dKLqXVtDX5V6dwqB0Xk+ihstpKEt3a1LT6X78A@mail.gmail.com1 parent2309eff commit9b282a9
File tree
6 files changed
+214
-21
lines changed- src
- backend
- optimizer
- path
- util
- utils/adt
- include/optimizer
- test/regress
- expected
- sql
6 files changed
+214
-21
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2443 | 2443 |
| |
2444 | 2444 |
| |
2445 | 2445 |
| |
2446 |
| - | |
2447 |
| - | |
2448 |
| - | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
2449 | 2451 |
| |
2450 | 2452 |
| |
2451 | 2453 |
| |
2452 | 2454 |
| |
2453 | 2455 |
| |
2454 |
| - | |
| 2456 | + | |
2455 | 2457 |
| |
2456 | 2458 |
| |
2457 | 2459 |
| |
| |||
2466 | 2468 |
| |
2467 | 2469 |
| |
2468 | 2470 |
| |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
2469 | 2482 |
| |
2470 | 2483 |
| |
2471 | 2484 |
| |
| |||
2494 | 2507 |
| |
2495 | 2508 |
| |
2496 | 2509 |
| |
2497 |
| - | |
2498 |
| - | |
| 2510 | + | |
2499 | 2511 |
| |
2500 | 2512 |
| |
2501 | 2513 |
| |
| |||
2536 | 2548 |
| |
2537 | 2549 |
| |
2538 | 2550 |
| |
2539 |
| - | |
| 2551 | + | |
2540 | 2552 |
| |
2541 | 2553 |
| |
2542 | 2554 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2080 | 2080 |
| |
2081 | 2081 |
| |
2082 | 2082 |
| |
| 2083 | + | |
| 2084 | + | |
2083 | 2085 |
| |
2084 |
| - | |
2085 |
| - | |
2086 |
| - | |
2087 | 2086 |
| |
2088 | 2087 |
| |
2089 | 2088 |
| |
| |||
2092 | 2091 |
| |
2093 | 2092 |
| |
2094 | 2093 |
| |
2095 |
| - | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
2096 | 2100 |
| |
2097 | 2101 |
| |
2098 | 2102 |
| |
2099 | 2103 |
| |
2100 | 2104 |
| |
2101 | 2105 |
| |
| 2106 | + | |
2102 | 2107 |
| |
2103 | 2108 |
| |
2104 | 2109 |
| |
| |||
2176 | 2181 |
| |
2177 | 2182 |
| |
2178 | 2183 |
| |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
2179 | 2188 |
| |
2180 | 2189 |
| |
2181 | 2190 |
| |
2182 | 2191 |
| |
2183 |
| - | |
| 2192 | + | |
2184 | 2193 |
| |
2185 | 2194 |
| |
2186 | 2195 |
| |
| |||
2192 | 2201 |
| |
2193 | 2202 |
| |
2194 | 2203 |
| |
2195 |
| - | |
| 2204 | + | |
| 2205 | + | |
| 2206 | + | |
| 2207 | + | |
| 2208 | + | |
2196 | 2209 |
| |
2197 | 2210 |
| |
2198 |
| - | |
2199 |
| - | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
| 2214 | + | |
| 2215 | + | |
| 2216 | + | |
| 2217 | + | |
| 2218 | + | |
2200 | 2219 |
| |
2201 |
| - | |
2202 |
| - | |
| 2220 | + | |
| 2221 | + | |
| 2222 | + | |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
2203 | 2284 |
| |
2204 | 2285 |
| |
2205 |
| - | |
| 2286 | + | |
2206 | 2287 |
| |
2207 | 2288 |
| |
2208 | 2289 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3313 | 3313 |
| |
3314 | 3314 |
| |
3315 | 3315 |
| |
3316 |
| - | |
| 3316 | + | |
| 3317 | + | |
3317 | 3318 |
| |
3318 | 3319 |
| |
3319 |
| - | |
| 3320 | + | |
3320 | 3321 |
| |
3321 | 3322 |
| |
3322 | 3323 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
158 | 158 |
| |
159 | 159 |
| |
160 | 160 |
| |
161 |
| - | |
| 161 | + | |
| 162 | + | |
162 | 163 |
| |
163 | 164 |
| |
164 | 165 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
65 | 104 |
| |
66 | 105 |
| |
67 | 106 |
| |
| |||
1803 | 1842 |
| |
1804 | 1843 |
| |
1805 | 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 | + | |
1806 | 1894 |
| |
1807 | 1895 |
| |
1808 | 1896 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
37 | 42 |
| |
38 | 43 |
| |
39 | 44 |
| |
| |||
386 | 391 |
| |
387 | 392 |
| |
388 | 393 |
| |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
389 | 399 |
| |
390 | 400 |
| |
391 | 401 |
| |
|
0 commit comments
Comments
(0)