forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9e21537
committed
Fix planner's use of Result Cache with unique joins
When the planner considered using a Result Cache node to cache resultsfrom the inner side of a Nested Loop Join, it failed to consider that theinner path's parameterization may not be the entire join condition. Ifthe join was marked as inner_unique then we may accidentally put the cachein singlerow mode. This meant that entries would be marked as completeafter caching the first row. That was wrong as if only part of the joincondition was parameterized then the uniqueness of the unique join was notguaranteed at the Result Cache's level. The uniqueness is only guaranteedafter Nested Loop applies the join filter. If subsequent rows were found,this would lead to:ERROR: cache entry already completeThis could have been fixed by only putting the cache in singlerow mode ifthe entire join condition was parameterized. However, Nested Loop willonly read its inner side so far as the first matching row when the join isunique, so that might mean we never get an opportunity to mark cacheentries as complete. Since non-complete cache entries are useless forsubsequent lookups, we just don't bother considering a Result Cache pathin this case.In passing, remove the XXX comment that claimed the above ERROR might bebetter suited to be an Assert. After there being an actual case whichtriggered it, it seems better to keep it an ERROR.Reported-by: David ChristensenDiscussion:https://postgr.es/m/CAOxo6X+dy-V58iEPFgst8ahPKEU+38NZzUuc+a7wDBZd4TrHMQ@mail.gmail.com1 parent0cdaa05 commit9e21537
File tree
2 files changed
+32
-1
lines changed- src/backend
- executor
- optimizer/path
2 files changed
+32
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
760 | 760 |
| |
761 | 761 |
| |
762 | 762 |
| |
763 |
| - | |
| 763 | + | |
764 | 764 |
| |
765 | 765 |
| |
766 | 766 |
| |
|
Lines changed: 31 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
503 | 503 |
| |
504 | 504 |
| |
505 | 505 |
| |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
506 | 537 |
| |
507 | 538 |
| |
508 | 539 |
| |
|
0 commit comments
Comments
(0)