- Notifications
You must be signed in to change notification settings - Fork5
Commitcffd89c
committed
Revise the planner's handling of "pseudoconstant" WHERE clauses, that is
clauses containing no variables and no volatile functions. Such a clausecan be used as a one-time qual in a gating Result plan node, to suppressplan execution entirely when it is false. Even when the clause is true,putting it in a gating node wins by avoiding repeated evaluation of theclause. In previous PG releases, query_planner() would do this forpseudoconstant clauses appearing at the top level of the jointree, butthere was no ability to generate a gating Result deeper in the plan tree.To fix it, get rid of the special case in query_planner(), and insteadprocess pseudoconstant clauses through the normal RestrictInfo qualdistribution mechanism. When a pseudoconstant clause is found attached toa path node in create_plan(), pull it out and generate a gating Result atthat point. This requires special-casing pseudoconstants in selectivityestimation and cost_qual_eval, but on the whole it's pretty clean.It probably even makes the planner a bit faster than before for the normalcase of no pseudoconstants, since removing pull_constant_clauses saves oneuseless traversal of the qual tree. Per gripe from Phil Frost.1 parent68628fc commitcffd89c
File tree
20 files changed
+465
-295
lines changed- src
- backend
- nodes
- optimizer
- path
- plan
- util
- include
- nodes
- optimizer
20 files changed
+465
-295
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| |||
1264 | 1264 | | |
1265 | 1265 | | |
1266 | 1266 | | |
| 1267 | + | |
1267 | 1268 | | |
1268 | 1269 | | |
1269 | 1270 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
1107 | 1107 | | |
1108 | 1108 | | |
1109 | 1109 | | |
1110 | | - | |
1111 | | - | |
| 1110 | + | |
1112 | 1111 | | |
1113 | 1112 | | |
1114 | 1113 | | |
| |||
1185 | 1184 | | |
1186 | 1185 | | |
1187 | 1186 | | |
| 1187 | + | |
1188 | 1188 | | |
1189 | 1189 | | |
1190 | 1190 | | |
| |||
1252 | 1252 | | |
1253 | 1253 | | |
1254 | 1254 | | |
| 1255 | + | |
1255 | 1256 | | |
1256 | 1257 | | |
1257 | 1258 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
450 | 452 | | |
451 | 453 | | |
452 | 454 | | |
| |||
466 | 468 | | |
467 | 469 | | |
468 | 470 | | |
469 | | - | |
| 471 | + | |
| 472 | + | |
470 | 473 | | |
471 | 474 | | |
472 | 475 | | |
| |||
1066 | 1069 | | |
1067 | 1070 | | |
1068 | 1071 | | |
1069 | | - | |
1070 | 1072 | | |
1071 | 1073 | | |
1072 | 1074 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
123 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
422 | 430 | | |
423 | 431 | | |
424 | 432 | | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
425 | 447 | | |
426 | 448 | | |
427 | 449 | | |
| |||
509 | 531 | | |
510 | 532 | | |
511 | 533 | | |
512 | | - | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
513 | 538 | | |
514 | 539 | | |
515 | 540 | | |
| |||
519 | 544 | | |
520 | 545 | | |
521 | 546 | | |
522 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
523 | 551 | | |
524 | 552 | | |
525 | 553 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
1604 | 1604 | | |
1605 | 1605 | | |
1606 | 1606 | | |
| 1607 | + | |
| 1608 | + | |
| 1609 | + | |
1607 | 1610 | | |
1608 | 1611 | | |
1609 | 1612 | | |
1610 | | - | |
| 1613 | + | |
1611 | 1614 | | |
1612 | | - | |
| 1615 | + | |
1613 | 1616 | | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
| 1617 | + | |
| 1618 | + | |
| 1619 | + | |
| 1620 | + | |
| 1621 | + | |
| 1622 | + | |
| 1623 | + | |
| 1624 | + | |
| 1625 | + | |
| 1626 | + | |
1618 | 1627 | | |
1619 | | - | |
1620 | | - | |
| 1628 | + | |
| 1629 | + | |
1621 | 1630 | | |
1622 | 1631 | | |
1623 | 1632 | | |
| |||
1876 | 1885 | | |
1877 | 1886 | | |
1878 | 1887 | | |
1879 | | - | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
1880 | 1891 | | |
1881 | 1892 | | |
1882 | 1893 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
998 | 998 | | |
999 | 999 | | |
1000 | 1000 | | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
1001 | 1010 | | |
1002 | 1011 | | |
1003 | 1012 | | |
| |||
2212 | 2221 | | |
2213 | 2222 | | |
2214 | 2223 | | |
| 2224 | + | |
2215 | 2225 | | |
2216 | 2226 | | |
2217 | 2227 | | |
| |||
2577 | 2587 | | |
2578 | 2588 | | |
2579 | 2589 | | |
2580 | | - | |
| 2590 | + | |
2581 | 2591 | | |
2582 | 2592 | | |
2583 | 2593 | | |
| |||
2586 | 2596 | | |
2587 | 2597 | | |
2588 | 2598 | | |
2589 | | - | |
| 2599 | + | |
2590 | 2600 | | |
2591 | 2601 | | |
2592 | 2602 | | |
| |||
2678 | 2688 | | |
2679 | 2689 | | |
2680 | 2690 | | |
2681 | | - | |
| 2691 | + | |
2682 | 2692 | | |
2683 | 2693 | | |
2684 | 2694 | | |
| |||
2693 | 2703 | | |
2694 | 2704 | | |
2695 | 2705 | | |
2696 | | - | |
| 2706 | + | |
2697 | 2707 | | |
2698 | 2708 | | |
2699 | 2709 | | |
| |||
2709 | 2719 | | |
2710 | 2720 | | |
2711 | 2721 | | |
2712 | | - | |
| 2722 | + | |
| 2723 | + | |
2713 | 2724 | | |
2714 | 2725 | | |
2715 | 2726 | | |
| |||
2772 | 2783 | | |
2773 | 2784 | | |
2774 | 2785 | | |
2775 | | - | |
| 2786 | + | |
2776 | 2787 | | |
2777 | 2788 | | |
2778 | 2789 | | |
| |||
2787 | 2798 | | |
2788 | 2799 | | |
2789 | 2800 | | |
2790 | | - | |
| 2801 | + | |
| 2802 | + | |
2791 | 2803 | | |
2792 | 2804 | | |
2793 | 2805 | | |
| |||
0 commit comments
Comments
(0)