forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2611285
committed
Fix OR-index-scan planner to recognize that a partial index is usable
for scanning one term of an OR clause if the index's predicate is impliedby that same OR clause term (possibly in conjunction with top-level WHEREclauses). Per recent example from Dawid Kuroczko,http://archives.postgresql.org/pgsql-performance/2004-10/msg00095.phpAlso, fix a very long-standing bug in index predicate testing, namely thebizarre ordering of decomposition of predicate and restriction clauses.AFAICS the correct way is to break down the predicate all the way, andthen for each component term see if you can prove it from the entirerestriction set. The original coding had a purely-implementation-artifactdistinction between ANDing at the top level and ANDing below that, andproceeded to get the decomposition order wrong everywhere below the toplevel, with the result that even slightly complicated AND/OR predicatescould not be proven. For instance, givencreate index foop on foo(f2) where f1=42 or f1=1 or (f1 = 11 and f2 = 55);the old code would fail to match this index to the queryselect * from foo where f1 = 11 and f2 = 55;when it obviously ought to match.1 parentc0c4883 commit2611285
File tree
3 files changed
+101
-74
lines changed- src
- backend/optimizer/path
- include/optimizer
3 files changed
+101
-74
lines changedLines changed: 67 additions & 68 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
9 | 9 |
| |
10 | 10 |
| |
11 | 11 |
| |
12 |
| - | |
| 12 | + | |
13 | 13 |
| |
14 | 14 |
| |
15 | 15 |
| |
| |||
64 | 64 |
| |
65 | 65 |
| |
66 | 66 |
| |
67 |
| - | |
| 67 | + | |
68 | 68 |
| |
69 |
| - | |
70 |
| - | |
| 69 | + | |
71 | 70 |
| |
72 | 71 |
| |
73 | 72 |
| |
| |||
750 | 749 |
| |
751 | 750 |
| |
752 | 751 |
| |
753 |
| - | |
754 |
| - | |
755 |
| - | |
756 |
| - | |
757 |
| - | |
758 |
| - | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
759 | 757 |
| |
760 |
| - | |
| 758 | + | |
761 | 759 |
| |
762 | 760 |
| |
763 | 761 |
| |
| |||
785 | 783 |
| |
786 | 784 |
| |
787 | 785 |
| |
788 |
| - | |
789 |
| - | |
| 786 | + | |
790 | 787 |
| |
791 |
| - | |
| 788 | + | |
792 | 789 |
| |
793 | 790 |
| |
794 | 791 |
| |
795 | 792 |
| |
796 | 793 |
| |
797 | 794 |
| |
798 | 795 |
| |
799 |
| - | |
| 796 | + | |
800 | 797 |
| |
801 |
| - | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
802 | 843 |
| |
803 | 844 |
| |
804 | 845 |
| |
| |||
809 | 850 |
| |
810 | 851 |
| |
811 | 852 |
| |
| 853 | + | |
| 854 | + | |
812 | 855 |
| |
813 |
| - | |
814 |
| - | |
| 856 | + | |
| 857 | + | |
815 | 858 |
| |
816 | 859 |
| |
817 | 860 |
| |
818 | 861 |
| |
819 | 862 |
| |
820 | 863 |
| |
821 | 864 |
| |
822 |
| - | |
823 |
| - | |
| 865 | + | |
| 866 | + | |
824 | 867 |
| |
825 |
| - | |
| 868 | + | |
826 | 869 |
| |
827 | 870 |
| |
828 |
| - | |
| 871 | + | |
829 | 872 |
| |
830 | 873 |
| |
831 | 874 |
| |
| |||
837 | 880 |
| |
838 | 881 |
| |
839 | 882 |
| |
840 |
| - | |
| 883 | + | |
841 | 884 |
| |
842 | 885 |
| |
843 | 886 |
| |
| |||
851 | 894 |
| |
852 | 895 |
| |
853 | 896 |
| |
854 |
| - | |
| 897 | + | |
855 | 898 |
| |
856 | 899 |
| |
857 | 900 |
| |
858 | 901 |
| |
859 |
| - | |
860 |
| - | |
861 |
| - | |
862 |
| - | |
863 |
| - | |
864 |
| - | |
865 |
| - | |
866 |
| - | |
867 |
| - | |
868 |
| - | |
869 |
| - | |
870 |
| - | |
871 |
| - | |
872 |
| - | |
873 |
| - | |
874 |
| - | |
875 |
| - | |
876 |
| - | |
877 |
| - | |
878 |
| - | |
879 |
| - | |
880 |
| - | |
881 |
| - | |
882 |
| - | |
883 |
| - | |
884 |
| - | |
885 |
| - | |
886 |
| - | |
887 |
| - | |
888 |
| - | |
889 |
| - | |
890 |
| - | |
891 |
| - | |
892 |
| - | |
893 |
| - | |
894 |
| - | |
895 |
| - | |
896 |
| - | |
897 |
| - | |
898 |
| - | |
899 |
| - | |
900 |
| - | |
901 |
| - | |
902 |
| - | |
903 | 902 |
| |
904 | 903 |
| |
905 | 904 |
| |
|
Lines changed: 32 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
355 | 355 |
| |
356 | 356 |
| |
357 | 357 |
| |
358 |
| - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
359 | 369 |
| |
360 |
| - | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
361 | 384 |
| |
362 | 385 |
| |
363 | 386 |
| |
364 | 387 |
| |
365 |
| - | |
366 |
| - | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
367 | 394 |
| |
368 | 395 |
| |
369 | 396 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
8 | 8 |
| |
9 | 9 |
| |
10 | 10 |
| |
11 |
| - | |
| 11 | + | |
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
| 47 | + | |
47 | 48 |
| |
48 | 49 |
| |
49 | 50 |
| |
|
0 commit comments
Comments
(0)