forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3af7040
committed
Fix IS [NOT] NULL qual optimization for inheritance tables
b262ad4 added code to have the planner remove redundant IS NOT NULLquals and eliminate needless scans for IS NULL quals on tables where thequal's column has a NOT NULL constraint.That commit failed to consider that an inheritance parent table couldhave differing NOT NULL constraints between the parent and the child.This caused issues as if we eliminated a qual on the parent, whenapplying the quals to child tables in apply_child_basequals(), the qualmight not have been added to the parent's baserestrictinfo.Here we fix this by not applying the optimization to remove redundantquals to RelOptInfos belonging to inheritance parents and applying theoptimization again in apply_child_basequals(). Effectively, this meansthat the parent and child are considered independently as the parent hasboth an inh=true and inh=false RTE and we still apply the optimizationto the RelOptInfo corresponding to the inh=false RTE.We're able to still apply the optimization in add_base_clause_to_rel()for partitioned tables as the NULLability of partitions must match thatof their parent. And, if we ever expand restriction_is_always_false()and restriction_is_always_true() to handle partition constraints then wecan apply the same logic as, even in multi-level partitioned tables,there's no way to route values to a partition when the qual does notmatch the partition qual of the partitioned table's parent partition.The same is true for CHECK constraints as those must also match betweenarent partitioned tables and their partitions.Author: Richard Guo, David RowleyDiscussion:https://postgr.es/m/CAMbWs4930gQSZmjR7aANzEapdy61gCg6z8dT-kAEYD0sYWKPdQ@mail.gmail.com1 parent6d4f062 commit3af7040
File tree
7 files changed
+182
-54
lines changed- src
- backend/optimizer
- plan
- util
- include/nodes
- test/regress
- expected
- sql
7 files changed
+182
-54
lines changedLines changed: 40 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
31 | 31 |
| |
32 | 32 |
| |
33 | 33 |
| |
| 34 | + | |
34 | 35 |
| |
35 | 36 |
| |
36 | 37 |
| |
| |||
2629 | 2630 |
| |
2630 | 2631 |
| |
2631 | 2632 |
| |
| 2633 | + | |
2632 | 2634 |
| |
2633 | 2635 |
| |
2634 | 2636 |
| |
2635 |
| - | |
2636 |
| - | |
2637 |
| - | |
2638 |
| - | |
2639 | 2637 |
| |
2640 |
| - | |
2641 |
| - | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
2642 | 2651 |
| |
2643 |
| - | |
| 2652 | + | |
2644 | 2653 |
| |
2645 |
| - | |
2646 |
| - | |
2647 |
| - | |
2648 |
| - | |
2649 |
| - | |
2650 |
| - | |
2651 |
| - | |
2652 |
| - | |
2653 |
| - | |
2654 |
| - | |
2655 |
| - | |
2656 |
| - | |
2657 |
| - | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
2658 | 2678 |
| |
2659 | 2679 |
| |
2660 | 2680 |
| |
|
Lines changed: 22 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
822 | 822 |
| |
823 | 823 |
| |
824 | 824 |
| |
825 |
| - | |
| 825 | + | |
| 826 | + | |
826 | 827 |
| |
827 | 828 |
| |
828 | 829 |
| |
829 |
| - | |
| 830 | + | |
| 831 | + | |
830 | 832 |
| |
831 | 833 |
| |
832 | 834 |
| |
| |||
875 | 877 |
| |
876 | 878 |
| |
877 | 879 |
| |
| 880 | + | |
878 | 881 |
| |
879 | 882 |
| |
880 | 883 |
| |
| |||
886 | 889 |
| |
887 | 890 |
| |
888 | 891 |
| |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 |
| - | |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 |
| - | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
898 | 909 |
| |
899 | 910 |
| |
900 | 911 |
| |
|
Lines changed: 24 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
161 | 161 |
| |
162 | 162 |
| |
163 | 163 |
| |
164 |
| - | |
165 |
| - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
166 | 174 |
| |
167 |
| - | |
168 |
| - | |
169 |
| - | |
| 175 | + | |
170 | 176 |
| |
171 |
| - | |
172 |
| - | |
| 177 | + | |
173 | 178 |
| |
174 |
| - | |
175 |
| - | |
176 |
| - | |
177 |
| - | |
178 |
| - | |
179 |
| - | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
180 | 191 |
| |
181 | 192 |
| |
182 | 193 |
| |
|
Lines changed: 16 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
373 | 373 |
| |
374 | 374 |
| |
375 | 375 |
| |
376 |
| - | |
377 |
| - | |
378 |
| - | |
379 |
| - | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
380 | 390 |
| |
381 | 391 |
| |
382 | 392 |
| |
| |||
386 | 396 |
| |
387 | 397 |
| |
388 | 398 |
| |
389 |
| - | |
390 |
| - | |
| 399 | + | |
| 400 | + | |
391 | 401 |
| |
392 | 402 |
| |
393 | 403 |
| |
394 | 404 |
| |
395 | 405 |
| |
396 |
| - | |
397 |
| - | |
398 |
| - | |
399 | 406 |
| |
400 | 407 |
| |
401 | 408 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
918 | 918 |
| |
919 | 919 |
| |
920 | 920 |
| |
921 |
| - | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
922 | 926 |
| |
923 | 927 |
| |
924 | 928 |
| |
|
Lines changed: 48 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
242 | 242 |
| |
243 | 243 |
| |
244 | 244 |
| |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + |
Lines changed: 27 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + |
0 commit comments
Comments
(0)