- Notifications
You must be signed in to change notification settings - Fork5
Commit7fa93ee
committed
Fix FK-based join selectivity estimation for semi/antijoins.
This case wasn't thought through sufficiently in commit100340e.It's true that the FK proves that every outer row has a match in theinner table, but we forgot that some of the inner rows might be filteredaway by WHERE conditions located within the semijoin's RHS.If the RHS is just one table, we can reasonably take the semijoinselectivity as equal to the fraction of the referenced table's rowsthat are expected to survive its restriction clauses.If the RHS is a join, it's not clear how much of the referenced tablemight get through the join, so fall back to the same rule we werealready using for other outer-join cases: use the minimum of theregular per-clause selectivity estimates. This gives the same resultas if we hadn't considered the FK at all when there's a single FKcolumn, but it should still help for multi-column FKs, which is thecase that100340e is really meant to help with.Back-patch to 9.6 where the previous commit came in.Discussion:https://postgr.es/m/16149.1481835103@sss.pgh.pa.us1 parentb645a05 commit7fa93ee
1 file changed
+53
-19
lines changedLines changed: 53 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4085 | 4085 |
| |
4086 | 4086 |
| |
4087 | 4087 |
| |
| 4088 | + | |
4088 | 4089 |
| |
4089 | 4090 |
| |
4090 | 4091 |
| |
| |||
4205 | 4206 |
| |
4206 | 4207 |
| |
4207 | 4208 |
| |
4208 |
| - | |
4209 |
| - | |
4210 |
| - | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
4211 | 4212 |
| |
4212 | 4213 |
| |
4213 | 4214 |
| |
| |||
4230 | 4231 |
| |
4231 | 4232 |
| |
4232 | 4233 |
| |
4233 |
| - | |
4234 |
| - | |
4235 |
| - | |
4236 |
| - | |
4237 |
| - | |
4238 |
| - | |
4239 |
| - | |
4240 |
| - | |
4241 |
| - | |
4242 |
| - | |
4243 |
| - | |
4244 |
| - | |
| 4234 | + | |
4245 | 4235 |
| |
4246 | 4236 |
| |
4247 | 4237 |
| |
4248 | 4238 |
| |
4249 | 4239 |
| |
4250 |
| - | |
4251 |
| - | |
4252 |
| - | |
4253 |
| - | |
| 4240 | + | |
| 4241 | + | |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
4254 | 4245 |
| |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
| 4252 | + | |
| 4253 | + | |
| 4254 | + | |
| 4255 | + | |
| 4256 | + | |
| 4257 | + | |
| 4258 | + | |
| 4259 | + | |
| 4260 | + | |
| 4261 | + | |
| 4262 | + | |
| 4263 | + | |
| 4264 | + | |
| 4265 | + | |
| 4266 | + | |
| 4267 | + | |
| 4268 | + | |
4255 | 4269 |
| |
4256 | 4270 |
| |
4257 | 4271 |
| |
| |||
4265 | 4279 |
| |
4266 | 4280 |
| |
4267 | 4281 |
| |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
| 4286 | + | |
| 4287 | + | |
| 4288 | + | |
| 4289 | + | |
| 4290 | + | |
| 4291 | + | |
| 4292 | + | |
| 4293 | + | |
| 4294 | + | |
| 4295 | + | |
| 4296 | + | |
| 4297 | + | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
4268 | 4302 |
| |
4269 | 4303 |
| |
4270 | 4304 |
| |
|
0 commit comments
Comments
(0)