- Notifications
You must be signed in to change notification settings - Fork5
Commit92a43e4
committed
Reduce semijoins with unique inner relations to plain inner joins.
If the inner relation can be proven unique, that is it can have no morethan one matching row for any row of the outer query, then we might aswell implement the semijoin as a plain inner join, allowing substantiallymore freedom to the planner. This is a form of outer join strengthreduction, but it can't be implemented in reduce_outer_joins() becausewe don't have enough info about the individual relations at that stage.Instead do it much like remove_useless_joins(): once we've built baserelations, we can make another pass over the SpecialJoinInfo list andget rid of any entries representing reducible semijoins.This is essentially a followon to the inner-unique patch (commit9c7f522)and makes use of the proof machinery that that patch created. We need onlyminor refactoring of innerrel_is_unique's API to support this usage.Per performance complaint from Teodor Sigaev.Discussion:https://postgr.es/m/f994fc98-389f-4a46-d1bc-c42e05cb43ed@sigaev.ru1 parent2057a58 commit92a43e4
File tree
7 files changed
+181
-27
lines changed- src
- backend/optimizer
- path
- plan
- include/optimizer
- test/regress
- expected
- sql
7 files changed
+181
-27
lines changedLines changed: 21 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
126 | 126 |
| |
127 | 127 |
| |
128 | 128 |
| |
129 |
| - | |
130 |
| - | |
131 |
| - | |
132 |
| - | |
133 |
| - | |
134 |
| - | |
135 |
| - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
136 | 138 |
| |
137 | 139 |
| |
138 | 140 |
| |
| |||
145 | 147 |
| |
146 | 148 |
| |
147 | 149 |
| |
148 |
| - | |
149 |
| - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
150 | 156 |
| |
151 | 157 |
| |
152 |
| - | |
153 |
| - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
154 | 164 |
| |
155 | 165 |
| |
156 | 166 |
| |
|
Lines changed: 108 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
| 45 | + | |
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| |||
495 | 495 |
| |
496 | 496 |
| |
497 | 497 |
| |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 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 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
498 | 580 |
| |
499 | 581 |
| |
500 | 582 |
| |
| |||
857 | 939 |
| |
858 | 940 |
| |
859 | 941 |
| |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
860 | 946 |
| |
861 | 947 |
| |
862 | 948 |
| |
| |||
867 | 953 |
| |
868 | 954 |
| |
869 | 955 |
| |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
870 | 960 |
| |
871 | 961 |
| |
872 | 962 |
| |
873 |
| - | |
| 963 | + | |
874 | 964 |
| |
875 | 965 |
| |
876 |
| - | |
| 966 | + | |
| 967 | + | |
877 | 968 |
| |
878 | 969 |
| |
879 | 970 |
| |
| |||
900 | 991 |
| |
901 | 992 |
| |
902 | 993 |
| |
903 |
| - | |
| 994 | + | |
904 | 995 |
| |
905 | 996 |
| |
906 | 997 |
| |
| |||
912 | 1003 |
| |
913 | 1004 |
| |
914 | 1005 |
| |
915 |
| - | |
| 1006 | + | |
916 | 1007 |
| |
917 | 1008 |
| |
918 | 1009 |
| |
919 | 1010 |
| |
920 |
| - | |
| 1011 | + | |
921 | 1012 |
| |
922 | 1013 |
| |
923 | 1014 |
| |
| |||
932 | 1023 |
| |
933 | 1024 |
| |
934 | 1025 |
| |
935 |
| - | |
| 1026 | + | |
936 | 1027 |
| |
937 | 1028 |
| |
938 | 1029 |
| |
| |||
949 | 1040 |
| |
950 | 1041 |
| |
951 | 1042 |
| |
952 |
| - | |
953 |
| - | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
954 | 1049 |
| |
955 |
| - | |
| 1050 | + | |
956 | 1051 |
| |
957 | 1052 |
| |
958 | 1053 |
| |
959 | 1054 |
| |
960 |
| - | |
| 1055 | + | |
961 | 1056 |
| |
962 | 1057 |
| |
963 | 1058 |
| |
| |||
972 | 1067 |
| |
973 | 1068 |
| |
974 | 1069 |
| |
975 |
| - | |
| 1070 | + | |
976 | 1071 |
| |
977 | 1072 |
| |
978 | 1073 |
| |
| |||
1007 | 1102 |
| |
1008 | 1103 |
| |
1009 | 1104 |
| |
1010 |
| - | |
| 1105 | + | |
1011 | 1106 |
| |
1012 | 1107 |
| |
1013 | 1108 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
192 | 192 |
| |
193 | 193 |
| |
194 | 194 |
| |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
195 | 201 |
| |
196 | 202 |
| |
197 | 203 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
106 | 107 |
| |
107 | 108 |
| |
108 | 109 |
| |
109 |
| - | |
110 |
| - | |
| 110 | + | |
| 111 | + | |
111 | 112 |
| |
112 | 113 |
| |
113 | 114 |
| |
|
Lines changed: 28 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5663 | 5663 |
| |
5664 | 5664 |
| |
5665 | 5665 |
| |
| 5666 | + | |
| 5667 | + | |
| 5668 | + | |
| 5669 | + | |
| 5670 | + | |
| 5671 | + | |
| 5672 | + | |
| 5673 | + | |
| 5674 | + | |
| 5675 | + | |
| 5676 | + | |
| 5677 | + | |
| 5678 | + | |
| 5679 | + | |
| 5680 | + | |
| 5681 | + | |
| 5682 | + | |
| 5683 | + | |
| 5684 | + | |
| 5685 | + | |
| 5686 | + | |
| 5687 | + | |
| 5688 | + | |
| 5689 | + | |
| 5690 | + | |
| 5691 | + | |
| 5692 | + | |
| 5693 | + |
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1673 | 1673 |
| |
1674 | 1674 |
| |
1675 | 1675 |
| |
1676 |
| - | |
| 1676 | + | |
1677 | 1677 |
| |
1678 | 1678 |
| |
1679 | 1679 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1864 | 1864 |
| |
1865 | 1865 |
| |
1866 | 1866 |
| |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
| 1876 | + | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + |
0 commit comments
Comments
(0)