- Notifications
You must be signed in to change notification settings - Fork5
Commit39df0f1
committed
Allow planner to use expression-index stats for function calls in WHERE.
Previously, a function call appearing at the top level of WHERE had ahard-wired selectivity estimate of 0.3333333, a kludge conveniently datedin the source code itself to July 1992. The expectation at the time wasthat somebody would soon implement estimator support functions analogousto those for operators; but no such code has appeared, nor does it seemlikely to in the near future. We do have an alternative solution though,at least for immutable functions on single relations: creating anexpression index on the function call will allow ANALYZE to gather statsabout the function's selectivity. But the code in clause_selectivity()failed to make use of such data even if it exists.Refactor so that that will happen. I chose to make it try this techniquefor any clause type for which clause_selectivity() doesn't have a specialcase, not just functions. To avoid adding unnecessary overhead in thecommon case where we don't learn anything new, make selfuncs.c provide anAPI that hooks directly to examine_variable() and then var_eq_const(),rather than the previous coding which laboriously constructed an OpExpronly so that it could be expensively deconstructed again.I preserved the behavior that the default estimate for a function callis 0.3333333. (For any other expression node type, it's 0.5, as before.)I had originally thought to make the default be 0.5 across the board, butchanging a default estimate that's survived for twenty-three years seemslike something not to do without a lot more testing than I care to putinto it right now.Per a complaint from Jehan-Guillaume de Rorthais. Back-patch into 9.5,but not further, at least for the moment.1 parent76f965f commit39df0f1
File tree
3 files changed
+59
-32
lines changed- src
- backend
- optimizer/path
- utils/adt
- include/utils
3 files changed
+59
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
568 | 567 | | |
569 | 568 | | |
570 | 569 | | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
| 570 | + | |
| 571 | + | |
583 | 572 | | |
584 | 573 | | |
585 | 574 | | |
| |||
680 | 669 | | |
681 | 670 | | |
682 | 671 | | |
683 | | - | |
684 | | - | |
685 | | - | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | 672 | | |
703 | 673 | | |
704 | 674 | | |
| |||
766 | 736 | | |
767 | 737 | | |
768 | 738 | | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
769 | 750 | | |
770 | 751 | | |
771 | 752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
| |||
1439 | 1440 | | |
1440 | 1441 | | |
1441 | 1442 | | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
1442 | 1487 | | |
1443 | 1488 | | |
1444 | 1489 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| 167 | + | |
167 | 168 | | |
168 | 169 | | |
169 | 170 | | |
| |||
0 commit comments
Comments
(0)