forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc676e65
committed
Fix choose_best_statistics to check clauses individually
When picking the best extended statistics object for a list of clauses,it's not enough to look at attnums extracted from the clause list as awhole. Consider for example this query with OR clauses: SELECT * FROM t WHERE (t.a = 1) OR (t.b = 1) OR (t.c = 1)with a statistics defined on columns (a,b). Relying on attnums extractedfrom the whole OR clause, we'd consider the statistics usable. That doesnot work, as we see the conditions as a single OR-clause, referencing anattribute not covered by the statistic, leading to empty list of clausesto be estimated using the statistics and an assert failure.This changes choose_best_statistics to check which clauses are actuallycovered, and only using attributes from the fully covered ones. For theprevious example this means the statistics object will not be consideredas compatible with the OR-clause.Backpatch to 12, where MCVs were introduced. The issue does not affectolder versions because functional dependencies don't handle OR clauses.Author: Tomas VondraReviewed-by: Dean RasheedReported-By: Manuel RiggerDiscussion:https://postgr.es/m/CA+u7OA7H5rcE2=8f263w4NZD6ipO_XOrYB816nuLXbmSTH9pQQ@mail.gmail.comBackpatch-through: 121 parent3974c4a commitc676e65
File tree
5 files changed
+81
-24
lines changed- src
- backend/statistics
- include/statistics
- test/regress
- expected
- sql
5 files changed
+81
-24
lines changedLines changed: 15 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
951 | 951 |
| |
952 | 952 |
| |
953 | 953 |
| |
954 |
| - | |
| 954 | + | |
955 | 955 |
| |
956 | 956 |
| |
957 | 957 |
| |
958 | 958 |
| |
959 | 959 |
| |
960 | 960 |
| |
961 |
| - | |
| 961 | + | |
962 | 962 |
| |
963 | 963 |
| |
964 | 964 |
| |
| |||
981 | 981 |
| |
982 | 982 |
| |
983 | 983 |
| |
984 |
| - | |
| 984 | + | |
985 | 985 |
| |
986 | 986 |
| |
987 | 987 |
| |
988 |
| - | |
| 988 | + | |
989 | 989 |
| |
990 | 990 |
| |
991 | 991 |
| |
| |||
1002 | 1002 |
| |
1003 | 1003 |
| |
1004 | 1004 |
| |
1005 |
| - | |
1006 |
| - | |
| 1005 | + | |
| 1006 | + | |
1007 | 1007 |
| |
1008 | 1008 |
| |
1009 | 1009 |
| |
| |||
1043 | 1043 |
| |
1044 | 1044 |
| |
1045 | 1045 |
| |
| 1046 | + | |
1046 | 1047 |
| |
1047 | 1048 |
| |
1048 | 1049 |
| |
1049 | 1050 |
| |
1050 | 1051 |
| |
1051 | 1052 |
| |
1052 |
| - | |
| 1053 | + | |
1053 | 1054 |
| |
1054 | 1055 |
| |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
1055 | 1061 |
| |
1056 | 1062 |
| |
1057 | 1063 |
| |
| |||
1061 | 1067 |
| |
1062 | 1068 |
| |
1063 | 1069 |
| |
1064 |
| - | |
1065 |
| - | |
| 1070 | + | |
1066 | 1071 |
| |
1067 | 1072 |
| |
1068 | 1073 |
| |
| |||
1077 | 1082 |
| |
1078 | 1083 |
| |
1079 | 1084 |
| |
1080 |
| - | |
1081 |
| - | |
| 1085 | + | |
1082 | 1086 |
| |
1083 | 1087 |
| |
1084 | 1088 |
| |
|
Lines changed: 29 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
844 | 844 |
| |
845 | 845 |
| |
846 | 846 |
| |
847 |
| - | |
848 |
| - | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
849 | 853 |
| |
850 | 854 |
| |
851 | 855 |
| |
852 | 856 |
| |
853 | 857 |
| |
854 | 858 |
| |
855 |
| - | |
| 859 | + | |
| 860 | + | |
856 | 861 |
| |
857 | 862 |
| |
858 | 863 |
| |
| |||
861 | 866 |
| |
862 | 867 |
| |
863 | 868 |
| |
| 869 | + | |
864 | 870 |
| |
| 871 | + | |
865 | 872 |
| |
866 | 873 |
| |
867 |
| - | |
868 | 874 |
| |
869 | 875 |
| |
870 | 876 |
| |
871 | 877 |
| |
872 | 878 |
| |
873 |
| - | |
874 |
| - | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
875 | 896 |
| |
876 | 897 |
| |
877 | 898 |
| |
| |||
1233 | 1254 |
| |
1234 | 1255 |
| |
1235 | 1256 |
| |
1236 |
| - | |
1237 |
| - | |
1238 |
| - | |
1239 |
| - | |
1240 | 1257 |
| |
1241 |
| - | |
| 1258 | + | |
| 1259 | + | |
1242 | 1260 |
| |
1243 | 1261 |
| |
1244 | 1262 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
121 |
| - | |
122 |
| - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
123 | 124 |
| |
124 | 125 |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
534 | 534 |
| |
535 | 535 |
| |
536 | 536 |
| |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
537 | 549 |
| |
538 | 550 |
| |
539 | 551 |
| |
| |||
573 | 585 |
| |
574 | 586 |
| |
575 | 587 |
| |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
576 | 601 |
| |
577 | 602 |
| |
578 | 603 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
342 | 342 |
| |
343 | 343 |
| |
344 | 344 |
| |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
345 | 349 |
| |
346 | 350 |
| |
347 | 351 |
| |
| |||
359 | 363 |
| |
360 | 364 |
| |
361 | 365 |
| |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
362 | 371 |
| |
363 | 372 |
| |
364 | 373 |
| |
|
0 commit comments
Comments
(0)