forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit19a5411
committed
Add an explicit representation of the output targetlist to Paths.
Up to now, there's been an assumption that all Paths for a given relationcompute the same output column set (targetlist). However, there are goodreasons to remove that assumption. For example, an indexscan on anexpression index might be able to return the value of an expensive function"for free". While we have the ability to generate such a plan today insimple cases, we don't have a way to model that it's cheaper than a planthat computes the function from scratch, nor a way to create such a planin join cases (where the function computation would normally happen atthe topmost join node). Also, we need this so that we can have Pathsrepresenting post-scan/join steps, where the targetlist may well changefrom one step to the next. Therefore, invent a "struct PathTarget"representing the columns we expect a plan step to emit. It's convenientto include the output tuple width and tlist evaluation cost in this struct,and there will likely be additional fields in future.While Path nodes that actually do have custom outputs will need their ownPathTargets, it will still be true that most Paths for a given relationwill compute the same tlist. To reduce the overhead added by this patch,keep a "default PathTarget" in RelOptInfo, and allow Paths that computethat column set to just point to their parent RelOptInfo's reltarget.(In the patch as committed, actually every Path is like that, since wedo not yet have any cases of custom PathTargets.)I took this opportunity to provide some more-honest costing ofPlaceHolderVar evaluation. Up to now, the assumption that "scan/joinreltargetlists have cost zero" was applied not only to Vars, where it'sreasonable, but also PlaceHolderVars where it isn't. Now, we add the evalcost of a PlaceHolderVar's expression to the first plan level where it canbe computed, by including it in the PathTarget cost field and adding thatto the cost estimates for Paths. This isn't perfect yet but it's muchbetter than before, and there is a way forward to improve it more. Thiscosting change affects the join order chosen for a couple of the regressiontests, changing expected row ordering.1 parent3386f34 commit19a5411
File tree
18 files changed
+326
-143
lines changed- contrib
- file_fdw
- postgres_fdw
- doc/src/sgml
- src
- backend
- nodes
- optimizer
- path
- plan
- util
- include
- nodes
- optimizer
- test/regress/expected
18 files changed
+326
-143
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
806 | 806 |
| |
807 | 807 |
| |
808 | 808 |
| |
809 |
| - | |
| 809 | + | |
810 | 810 |
| |
811 | 811 |
| |
812 | 812 |
| |
| |||
938 | 938 |
| |
939 | 939 |
| |
940 | 940 |
| |
941 |
| - | |
| 941 | + | |
942 | 942 |
| |
943 | 943 |
| |
944 | 944 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
728 | 728 |
| |
729 | 729 |
| |
730 | 730 |
| |
731 |
| - | |
| 731 | + | |
732 | 732 |
| |
733 | 733 |
| |
734 |
| - | |
| 734 | + | |
735 | 735 |
| |
736 | 736 |
| |
737 | 737 |
| |
|
Lines changed: 6 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
479 | 479 |
| |
480 | 480 |
| |
481 | 481 |
| |
482 |
| - | |
| 482 | + | |
483 | 483 |
| |
484 | 484 |
| |
485 | 485 |
| |
| |||
522 | 522 |
| |
523 | 523 |
| |
524 | 524 |
| |
525 |
| - | |
| 525 | + | |
526 | 526 |
| |
527 | 527 |
| |
528 | 528 |
| |
| |||
539 | 539 |
| |
540 | 540 |
| |
541 | 541 |
| |
542 |
| - | |
| 542 | + | |
| 543 | + | |
543 | 544 |
| |
544 | 545 |
| |
545 | 546 |
| |
| |||
2176 | 2177 |
| |
2177 | 2178 |
| |
2178 | 2179 |
| |
2179 |
| - | |
| 2180 | + | |
2180 | 2181 |
| |
2181 | 2182 |
| |
2182 | 2183 |
| |
| |||
3646 | 3647 |
| |
3647 | 3648 |
| |
3648 | 3649 |
| |
3649 |
| - | |
| 3650 | + | |
3650 | 3651 |
| |
3651 | 3652 |
| |
3652 | 3653 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1159 | 1159 |
| |
1160 | 1160 |
| |
1161 | 1161 |
| |
1162 |
| - | |
| 1162 | + | |
1163 | 1163 |
| |
1164 | 1164 |
| |
1165 | 1165 |
| |
|
Lines changed: 13 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1589 | 1589 |
| |
1590 | 1590 |
| |
1591 | 1591 |
| |
| 1592 | + | |
1592 | 1593 |
| |
1593 | 1594 |
| |
1594 | 1595 |
| |
| |||
1598 | 1599 |
| |
1599 | 1600 |
| |
1600 | 1601 |
| |
1601 |
| - | |
1602 |
| - | |
1603 |
| - | |
1604 |
| - | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
| 1605 | + | |
| 1606 | + | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
1605 | 1610 |
| |
1606 | 1611 |
| |
1607 | 1612 |
| |
| |||
1901 | 1906 |
| |
1902 | 1907 |
| |
1903 | 1908 |
| |
1904 |
| - | |
1905 | 1909 |
| |
1906 | 1910 |
| |
1907 | 1911 |
| |
1908 |
| - | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
1909 | 1916 |
| |
1910 | 1917 |
| |
1911 | 1918 |
| |
|
Lines changed: 19 additions & 18 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
919 | 919 |
| |
920 | 920 |
| |
921 | 921 |
| |
922 |
| - | |
923 |
| - | |
| 922 | + | |
| 923 | + | |
924 | 924 |
| |
925 |
| - | |
926 |
| - | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
927 | 928 |
| |
928 | 929 |
| |
929 | 930 |
| |
930 | 931 |
| |
931 | 932 |
| |
932 |
| - | |
| 933 | + | |
933 | 934 |
| |
934 |
| - | |
| 935 | + | |
935 | 936 |
| |
936 | 937 |
| |
937 | 938 |
| |
| |||
976 | 977 |
| |
977 | 978 |
| |
978 | 979 |
| |
979 |
| - | |
| 980 | + | |
980 | 981 |
| |
981 | 982 |
| |
982 | 983 |
| |
983 | 984 |
| |
984 | 985 |
| |
985 | 986 |
| |
986 | 987 |
| |
987 |
| - | |
| 988 | + | |
988 | 989 |
| |
989 |
| - | |
990 |
| - | |
| 990 | + | |
| 991 | + | |
991 | 992 |
| |
992 | 993 |
| |
993 | 994 |
| |
| |||
1022 | 1023 |
| |
1023 | 1024 |
| |
1024 | 1025 |
| |
1025 |
| - | |
| 1026 | + | |
1026 | 1027 |
| |
1027 | 1028 |
| |
1028 | 1029 |
| |
| |||
1495 | 1496 |
| |
1496 | 1497 |
| |
1497 | 1498 |
| |
1498 |
| - | |
| 1499 | + | |
1499 | 1500 |
| |
1500 | 1501 |
| |
1501 | 1502 |
| |
| |||
1728 | 1729 |
| |
1729 | 1730 |
| |
1730 | 1731 |
| |
1731 |
| - | |
1732 |
| - | |
1733 |
| - | |
| 1732 | + | |
| 1733 | + | |
| 1734 | + | |
1734 | 1735 |
| |
1735 |
| - | |
| 1736 | + | |
1736 | 1737 |
| |
1737 | 1738 |
| |
1738 | 1739 |
| |
| |||
2676 | 2677 |
| |
2677 | 2678 |
| |
2678 | 2679 |
| |
2679 |
| - | |
| 2680 | + | |
2680 | 2681 |
| |
2681 | 2682 |
| |
2682 | 2683 |
| |
2683 |
| - | |
| 2684 | + | |
2684 | 2685 |
| |
2685 | 2686 |
| |
2686 | 2687 |
| |
|
0 commit comments
Comments
(0)