- Notifications
You must be signed in to change notification settings - Fork28
Commitccaa356
committed
Recognize some OR clauses as compatible with functional dependencies
Since commit8f321bd functional dependencies can handle IN clauses,which however introduced a possible (and surprising) inconsistency,because IN clauses may be expressed as an OR clause, which are stillconsidered incompatible. For example a IN (1, 2, 3)may be rewritten as (a = 1 OR a = 2 OR a = 3)The IN clause will work fine with functional dependencies, but the ORclause will force the estimation to fall back to plain per-columnestimates, possibly introducing significant estimation errors.This commit recognizes OR clauses equivalent to an IN clause (when allarugments are compatible and reference the same attribute) as a specialcase, compatible with functional dependencies. This allows applyingfunctional dependencies, just like for IN clauses.This does not eliminate the difference in estimating the clause itself,i.e. IN clause and OR clause still use different formulas. It would bepossible to change that (for these special OR clauses), but that's notreally about extended statistics - it was always like this. Moreover theerrors are usually much smaller compared to ignoring dependencies.Author: Tomas VondraReviewed-by: Dean RasheedDiscussion:https://www.postgresql.org/message-id/flat/13902317.Eha0YfKkKy%40pierred-pdoc1 parentdbe0d98 commitccaa356
File tree
3 files changed
+121
-16
lines changed- src
- backend/statistics
- test/regress
- expected
- sql
3 files changed
+121
-16
lines changedLines changed: 49 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
753 | 753 |
| |
754 | 754 |
| |
755 | 755 |
| |
756 |
| - | |
757 | 756 |
| |
758 | 757 |
| |
759 |
| - | |
760 |
| - | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
761 | 761 |
| |
762 |
| - | |
763 |
| - | |
764 |
| - | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
765 | 765 |
| |
766 |
| - | |
767 |
| - | |
768 |
| - | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
769 | 769 |
| |
770 |
| - | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
771 | 774 |
| |
772 | 775 |
| |
773 |
| - | |
| 776 | + | |
774 | 777 |
| |
775 | 778 |
| |
776 | 779 |
| |
| |||
801 | 804 |
| |
802 | 805 |
| |
803 | 806 |
| |
804 |
| - | |
| 807 | + | |
805 | 808 |
| |
806 | 809 |
| |
807 |
| - | |
| 810 | + | |
808 | 811 |
| |
809 | 812 |
| |
810 | 813 |
| |
| |||
839 | 842 |
| |
840 | 843 |
| |
841 | 844 |
| |
842 |
| - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
843 | 876 |
| |
844 | 877 |
| |
845 | 878 |
| |
846 | 879 |
| |
847 | 880 |
| |
848 |
| - | |
| 881 | + | |
849 | 882 |
| |
850 | 883 |
| |
851 | 884 |
| |
852 | 885 |
| |
853 | 886 |
| |
854 | 887 |
| |
855 | 888 |
| |
856 |
| - | |
| 889 | + | |
857 | 890 |
| |
858 | 891 |
| |
859 | 892 |
| |
|
Lines changed: 52 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
458 | 458 |
| |
459 | 459 |
| |
460 | 460 |
| |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
461 | 487 |
| |
462 | 488 |
| |
463 | 489 |
| |
| |||
592 | 618 |
| |
593 | 619 |
| |
594 | 620 |
| |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
595 | 647 |
| |
596 | 648 |
| |
597 | 649 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
286 | 286 |
| |
287 | 287 |
| |
288 | 288 |
| |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
289 | 299 |
| |
290 | 300 |
| |
291 | 301 |
| |
| |||
338 | 348 |
| |
339 | 349 |
| |
340 | 350 |
| |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
341 | 361 |
| |
342 | 362 |
| |
343 | 363 |
| |
|
0 commit comments
Comments
(0)