forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit43f0c20
committed
Fix overoptimistic assumptions in column width estimation for subqueries.
set_append_rel_pathlist supposed that, while computing per-column widthestimates for the appendrel, it could ignore child rels for which thetranslated reltargetlist entry wasn't a Var. This gave rise to completelysilly estimates in some common cases, such as constant outputs from some orall of the arms of a UNION ALL. Instead, fall back on get_typavgwidth toestimate from the value's datatype; which might be a poor estimate but atleast it's not completely wacko.That problem was exposed by an Assert in set_subquery_size_estimates, whichunfortunately was still overoptimistic even with that fix, since we don'tcompute attr_widths estimates for appendrels that are entirely excluded byconstraints. So remove the Assert; we'll just fall back on get_typavgwidthin such cases.Also, since set_subquery_size_estimates calls set_baserel_size_estimateswhich calls set_rel_width, there's no need for set_subquery_size_estimatesto call get_typavgwidth; set_rel_width will handle it for us if we justleave the estimate set to zero. Remove the unnecessary code.Per report from Erik Rijkers and subsequent investigation.1 parent1af55e2 commit43f0c20
2 files changed
+44
-22
lines changedLines changed: 33 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
403 | 403 |
| |
404 | 404 |
| |
405 | 405 |
| |
406 |
| - | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
407 | 415 |
| |
408 | 416 |
| |
409 | 417 |
| |
| |||
486 | 494 |
| |
487 | 495 |
| |
488 | 496 |
| |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
489 | 505 |
| |
490 | 506 |
| |
491 | 507 |
| |
492 | 508 |
| |
493 |
| - | |
494 |
| - | |
495 |
| - | |
496 |
| - | |
497 |
| - | |
498 |
| - | |
499 |
| - | |
500 |
| - | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
501 | 512 |
| |
502 | 513 |
| |
503 |
| - | |
504 |
| - | |
505 |
| - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
506 | 527 |
| |
507 | 528 |
| |
508 | 529 |
| |
|
Lines changed: 11 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3238 | 3238 |
| |
3239 | 3239 |
| |
3240 | 3240 |
| |
3241 |
| - | |
3242 |
| - | |
| 3241 | + | |
| 3242 | + | |
3243 | 3243 |
| |
3244 | 3244 |
| |
3245 | 3245 |
| |
3246 | 3246 |
| |
3247 | 3247 |
| |
3248 |
| - | |
| 3248 | + | |
3249 | 3249 |
| |
3250 | 3250 |
| |
3251 | 3251 |
| |
| |||
3256 | 3256 |
| |
3257 | 3257 |
| |
3258 | 3258 |
| |
3259 |
| - | |
3260 |
| - | |
| 3259 | + | |
| 3260 | + | |
| 3261 | + | |
| 3262 | + | |
| 3263 | + | |
| 3264 | + | |
| 3265 | + | |
| 3266 | + | |
3261 | 3267 |
| |
3262 | 3268 |
| |
3263 | 3269 |
| |
| |||
3267 | 3273 |
| |
3268 | 3274 |
| |
3269 | 3275 |
| |
3270 |
| - | |
3271 |
| - | |
3272 |
| - | |
3273 |
| - | |
3274 |
| - | |
3275 | 3276 |
| |
3276 | 3277 |
| |
3277 | 3278 |
| |
|
0 commit comments
Comments
(0)