forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9d1a535
committed
Fix costing bug in MergeAppend
When building a MergeAppendPath which has child paths that are notsorted correctly for the MergeAppend's sort order, we apply the cost ofsorting those paths to the MergeAppendPath costs.Here we fix a bug where the number of tuples specified that needed to besorted was effectively pg_class.reltuples rather than the number ofexpected row in the subpath. This effectively penalizes MergeAppendplans any time any filter is present on the MergeAppend subpath as thesort cost added is to sort all tuples in the table rather than just theones expected the path to return.This did not affect UNION ALL type queries as the RelOptInfo tuples isset from the subquery's path rows. It does affect MergeAppends uses forinheritance and partitioned tables.This is a long-standing bug introduced when MergeAppend was first addedin11cad29. No backpatch as this could result in plan changes.Author: Alexander KuzmenkovReviewed-by: Ashutosh Bapat, Aleksander Alekseev, David RowleyDiscussion:https://postgr.es/m/CALzhyqyhoXQDR-Usd_0HeWk%3DuqNLzoVeT8KhRoo%3DpV_KzgO3QQ%40mail.gmail.com1 parent9589b03 commit9d1a535
File tree
3 files changed
+37
-1
lines changed- src
- backend/optimizer/util
- test/regress
- expected
- sql
3 files changed
+37
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1470 | 1470 |
| |
1471 | 1471 |
| |
1472 | 1472 |
| |
1473 |
| - | |
| 1473 | + | |
1474 | 1474 |
| |
1475 | 1475 |
| |
1476 | 1476 |
| |
|
Lines changed: 23 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1714 | 1714 |
| |
1715 | 1715 |
| |
1716 | 1716 |
| |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
| 1724 | + | |
| 1725 | + | |
| 1726 | + | |
| 1727 | + | |
| 1728 | + | |
| 1729 | + | |
| 1730 | + | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1717 | 1740 |
| |
1718 | 1741 |
| |
1719 | 1742 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
624 | 624 |
| |
625 | 625 |
| |
626 | 626 |
| |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
627 | 640 |
| |
628 | 641 |
| |
629 | 642 |
| |
|
0 commit comments
Comments
(0)