forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit7e5d20b
committed
Disable run condition optimization for some WindowFuncs
94985c2 added code to detect when WindowFuncs were monotonic andallowed additional quals to be "pushed down" into the subquery to beused as WindowClause runConditions in order to short-circuit executionin nodeWindowAgg.c.The Node representation of runConditions wasn't well selected andbecause we do qual pushdown before planning the subquery, the planningof the subquery could perform subquery pull-up of nested subqueries.For WindowFuncs with args, the arguments could be changed after pushingthe qual down to the subquery.This was made more difficult by the fact that the code duplicated theWindowFunc inside an OpExpr to include in the WindowClauses runConditionfield. This could result in duplication of subqueries and a pull-up ofsuch a subquery could result in another initplan parameter being issuedfor the 2nd version of the subplan. This could result in errors such as:ERROR: WindowFunc not found in subplan target listsHere in the backbranches, we don't have the flexibility to improve theNode representation to resolve this, so instead we just disable therunCondition optimization for ntile() unless the argument is a Const,(v16 only) and likewise for count(expr) (both v15 and v16). count(*) isunaffected. All other window functions which support this optimizationall take zero arguments and therefore are unaffected.Bug: #18170Reported-by: Zuming JiangDiscussion:https://postgr.es/m/18170-f1d17bf9a0d58b24@postgresql.orgBackpatch-through 15 (master will be fixed independently)1 parentfaba2f8 commit7e5d20b
File tree
4 files changed
+67
-24
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
4 files changed
+67
-24
lines changedLines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
833 | 833 |
| |
834 | 834 |
| |
835 | 835 |
| |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
836 | 851 |
| |
837 | 852 |
| |
838 | 853 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
14 | 14 |
| |
15 | 15 |
| |
16 | 16 |
| |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
|
Lines changed: 34 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3481 | 3481 |
| |
3482 | 3482 |
| |
3483 | 3483 |
| |
3484 |
| - | |
| 3484 | + | |
3485 | 3485 |
| |
3486 | 3486 |
| |
3487 |
| - | |
3488 |
| - | |
| 3487 | + | |
| 3488 | + | |
3489 | 3489 |
| |
3490 |
| - | |
| 3490 | + | |
3491 | 3491 |
| |
3492 | 3492 |
| |
3493 | 3493 |
| |
| |||
3496 | 3496 |
| |
3497 | 3497 |
| |
3498 | 3498 |
| |
3499 |
| - | |
| 3499 | + | |
3500 | 3500 |
| |
3501 | 3501 |
| |
3502 | 3502 |
| |
| |||
3608 | 3608 |
| |
3609 | 3609 |
| |
3610 | 3610 |
| |
3611 |
| - | |
| 3611 | + | |
3612 | 3612 |
| |
3613 | 3613 |
| |
3614 | 3614 |
| |
3615 | 3615 |
| |
3616 | 3616 |
| |
3617 |
| - | |
| 3617 | + | |
3618 | 3618 |
| |
3619 | 3619 |
| |
3620 | 3620 |
| |
3621 | 3621 |
| |
3622 | 3622 |
| |
3623 |
| - | |
| 3623 | + | |
3624 | 3624 |
| |
3625 | 3625 |
| |
3626 | 3626 |
| |
| |||
3631 | 3631 |
| |
3632 | 3632 |
| |
3633 | 3633 |
| |
3634 |
| - | |
| 3634 | + | |
3635 | 3635 |
| |
3636 | 3636 |
| |
3637 | 3637 |
| |
| |||
3653 | 3653 |
| |
3654 | 3654 |
| |
3655 | 3655 |
| |
3656 |
| - | |
| 3656 | + | |
3657 | 3657 |
| |
3658 | 3658 |
| |
3659 |
| - | |
3660 |
| - | |
| 3659 | + | |
| 3660 | + | |
3661 | 3661 |
| |
3662 |
| - | |
| 3662 | + | |
3663 | 3663 |
| |
3664 | 3664 |
| |
3665 | 3665 |
| |
3666 | 3666 |
| |
3667 | 3667 |
| |
3668 | 3668 |
| |
3669 | 3669 |
| |
3670 |
| - | |
| 3670 | + | |
3671 | 3671 |
| |
3672 | 3672 |
| |
3673 | 3673 |
| |
| |||
3678 | 3678 |
| |
3679 | 3679 |
| |
3680 | 3680 |
| |
3681 |
| - | |
| 3681 | + | |
3682 | 3682 |
| |
3683 | 3683 |
| |
3684 | 3684 |
| |
| |||
3694 | 3694 |
| |
3695 | 3695 |
| |
3696 | 3696 |
| |
3697 |
| - | |
| 3697 | + | |
3698 | 3698 |
| |
3699 | 3699 |
| |
3700 | 3700 |
| |
| |||
3765 | 3765 |
| |
3766 | 3766 |
| |
3767 | 3767 |
| |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
3768 | 3786 |
| |
3769 | 3787 |
| |
3770 | 3788 |
| |
|
Lines changed: 17 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1068 | 1068 |
| |
1069 | 1069 |
| |
1070 | 1070 |
| |
1071 |
| - | |
| 1071 | + | |
1072 | 1072 |
| |
1073 | 1073 |
| |
1074 | 1074 |
| |
1075 | 1075 |
| |
1076 | 1076 |
| |
1077 | 1077 |
| |
1078 |
| - | |
| 1078 | + | |
1079 | 1079 |
| |
1080 | 1080 |
| |
1081 | 1081 |
| |
| |||
1131 | 1131 |
| |
1132 | 1132 |
| |
1133 | 1133 |
| |
1134 |
| - | |
| 1134 | + | |
1135 | 1135 |
| |
1136 | 1136 |
| |
1137 | 1137 |
| |
1138 | 1138 |
| |
1139 | 1139 |
| |
1140 |
| - | |
| 1140 | + | |
1141 | 1141 |
| |
1142 | 1142 |
| |
1143 | 1143 |
| |
| |||
1146 | 1146 |
| |
1147 | 1147 |
| |
1148 | 1148 |
| |
1149 |
| - | |
| 1149 | + | |
1150 | 1150 |
| |
1151 | 1151 |
| |
1152 | 1152 |
| |
| |||
1157 | 1157 |
| |
1158 | 1158 |
| |
1159 | 1159 |
| |
1160 |
| - | |
| 1160 | + | |
1161 | 1161 |
| |
1162 | 1162 |
| |
1163 | 1163 |
| |
1164 | 1164 |
| |
1165 | 1165 |
| |
1166 | 1166 |
| |
1167 | 1167 |
| |
1168 |
| - | |
| 1168 | + | |
1169 | 1169 |
| |
1170 | 1170 |
| |
1171 | 1171 |
| |
| |||
1175 | 1175 |
| |
1176 | 1176 |
| |
1177 | 1177 |
| |
1178 |
| - | |
| 1178 | + | |
1179 | 1179 |
| |
1180 | 1180 |
| |
1181 | 1181 |
| |
| |||
1215 | 1215 |
| |
1216 | 1216 |
| |
1217 | 1217 |
| |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1218 | 1227 |
| |
1219 | 1228 |
| |
1220 | 1229 |
| |
|
0 commit comments
Comments
(0)