- Notifications
You must be signed in to change notification settings - Fork5.2k
Commit931766a
committed
Simplify COALESCE() with one surviving argument.
If, after removal of useless null-constant arguments, a CoalesceExprhas exactly one remaining argument, we can just take that argument asthe result, without bothering to wrap a new CoalesceExpr around it.This isn't likely to produce any great improvement in runtime per se,but it can lead to better plans since the planner no longer has totreat the expression as non-strict.However, there were a few regression test cases that intentionallywrote COALESCE(x) as a shorthand way of creating a non-strictsubexpression. To avoid ruining the intent of those tests, writeCOALESCE(x,x) instead. (If anyone ever proposes de-duplicatingCOALESCE arguments, we'll need another iteration of this arms race.But it seems pretty unlikely that such an optimization would beworthwhile.)Author: Maksim Milyutin <maksim.milyutin@tantorlabs.ru>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/8e8573c3-1411-448d-877e-53258b7b2be0@tantorlabs.ru1 parentfc89682 commit931766a
File tree
5 files changed
+55
-48
lines changed- src
- backend/optimizer/util
- test/regress
- expected
- sql
5 files changed
+55
-48
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3333 | 3333 | | |
3334 | 3334 | | |
3335 | 3335 | | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
3336 | 3343 | | |
3337 | 3344 | | |
3338 | 3345 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5626 | 5626 | | |
5627 | 5627 | | |
5628 | 5628 | | |
5629 | | - | |
5630 | | - | |
5631 | | - | |
| 5629 | + | |
| 5630 | + | |
| 5631 | + | |
5632 | 5632 | | |
5633 | 5633 | | |
5634 | 5634 | | |
5635 | 5635 | | |
5636 | | - | |
| 5636 | + | |
5637 | 5637 | | |
5638 | 5638 | | |
5639 | 5639 | | |
| |||
5643 | 5643 | | |
5644 | 5644 | | |
5645 | 5645 | | |
5646 | | - | |
| 5646 | + | |
5647 | 5647 | | |
5648 | 5648 | | |
5649 | 5649 | | |
| |||
8411 | 8411 | | |
8412 | 8412 | | |
8413 | 8413 | | |
8414 | | - | |
8415 | | - | |
8416 | | - | |
| 8414 | + | |
| 8415 | + | |
| 8416 | + | |
8417 | 8417 | | |
8418 | | - | |
| 8418 | + | |
8419 | 8419 | | |
8420 | 8420 | | |
8421 | 8421 | | |
8422 | | - | |
| 8422 | + | |
8423 | 8423 | | |
8424 | 8424 | | |
8425 | 8425 | | |
8426 | 8426 | | |
8427 | | - | |
| 8427 | + | |
8428 | 8428 | | |
8429 | 8429 | | |
8430 | 8430 | | |
| |||
9593 | 9593 | | |
9594 | 9594 | | |
9595 | 9595 | | |
9596 | | - | |
| 9596 | + | |
9597 | 9597 | | |
9598 | | - | |
9599 | | - | |
| 9598 | + | |
| 9599 | + | |
9600 | 9600 | | |
9601 | | - | |
| 9601 | + | |
9602 | 9602 | | |
9603 | | - | |
| 9603 | + | |
9604 | 9604 | | |
9605 | 9605 | | |
9606 | 9606 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2127 | 2127 | | |
2128 | 2128 | | |
2129 | 2129 | | |
2130 | | - | |
| 2130 | + | |
2131 | 2131 | | |
2132 | 2132 | | |
2133 | 2133 | | |
2134 | | - | |
2135 | | - | |
| 2134 | + | |
| 2135 | + | |
2136 | 2136 | | |
2137 | | - | |
2138 | | - | |
| 2137 | + | |
| 2138 | + | |
2139 | 2139 | | |
2140 | | - | |
| 2140 | + | |
2141 | 2141 | | |
2142 | 2142 | | |
2143 | | - | |
| 2143 | + | |
2144 | 2144 | | |
2145 | 2145 | | |
2146 | | - | |
| 2146 | + | |
2147 | 2147 | | |
2148 | 2148 | | |
2149 | 2149 | | |
2150 | 2150 | | |
2151 | | - | |
| 2151 | + | |
2152 | 2152 | | |
2153 | | - | |
| 2153 | + | |
2154 | 2154 | | |
2155 | 2155 | | |
2156 | 2156 | | |
| |||
2164 | 2164 | | |
2165 | 2165 | | |
2166 | 2166 | | |
2167 | | - | |
| 2167 | + | |
2168 | 2168 | | |
2169 | 2169 | | |
2170 | 2170 | | |
| |||
2201 | 2201 | | |
2202 | 2202 | | |
2203 | 2203 | | |
2204 | | - | |
| 2204 | + | |
2205 | 2205 | | |
2206 | 2206 | | |
2207 | 2207 | | |
2208 | | - | |
2209 | | - | |
| 2208 | + | |
| 2209 | + | |
2210 | 2210 | | |
2211 | | - | |
2212 | | - | |
| 2211 | + | |
| 2212 | + | |
2213 | 2213 | | |
2214 | | - | |
| 2214 | + | |
2215 | 2215 | | |
2216 | 2216 | | |
2217 | | - | |
| 2217 | + | |
2218 | 2218 | | |
2219 | 2219 | | |
2220 | | - | |
| 2220 | + | |
2221 | 2221 | | |
2222 | 2222 | | |
2223 | 2223 | | |
2224 | 2224 | | |
2225 | | - | |
| 2225 | + | |
2226 | 2226 | | |
2227 | | - | |
| 2227 | + | |
2228 | 2228 | | |
2229 | | - | |
| 2229 | + | |
2230 | 2230 | | |
2231 | 2231 | | |
2232 | 2232 | | |
| |||
2236 | 2236 | | |
2237 | 2237 | | |
2238 | 2238 | | |
2239 | | - | |
| 2239 | + | |
2240 | 2240 | | |
2241 | 2241 | | |
2242 | 2242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1977 | 1977 | | |
1978 | 1978 | | |
1979 | 1979 | | |
1980 | | - | |
| 1980 | + | |
1981 | 1981 | | |
1982 | 1982 | | |
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
1986 | | - | |
| 1986 | + | |
1987 | 1987 | | |
1988 | 1988 | | |
1989 | 1989 | | |
| |||
3169 | 3169 | | |
3170 | 3170 | | |
3171 | 3171 | | |
3172 | | - | |
| 3172 | + | |
3173 | 3173 | | |
3174 | | - | |
| 3174 | + | |
3175 | 3175 | | |
3176 | 3176 | | |
3177 | 3177 | | |
| |||
3637 | 3637 | | |
3638 | 3638 | | |
3639 | 3639 | | |
3640 | | - | |
| 3640 | + | |
3641 | 3641 | | |
3642 | 3642 | | |
3643 | 3643 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1041 | 1041 | | |
1042 | 1042 | | |
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 | 1055 | | |
| |||
1059 | 1059 | | |
1060 | 1060 | | |
1061 | 1061 | | |
1062 | | - | |
| 1062 | + | |
1063 | 1063 | | |
1064 | 1064 | | |
1065 | 1065 | | |
1066 | 1066 | | |
1067 | 1067 | | |
1068 | 1068 | | |
1069 | 1069 | | |
1070 | | - | |
| 1070 | + | |
1071 | 1071 | | |
1072 | 1072 | | |
1073 | 1073 | | |
| |||
0 commit comments
Comments
(0)