- Notifications
You must be signed in to change notification settings - Fork5.3k
Commit42473b3
committed
Have the planner replace COUNT(ANY) with COUNT(*), when possible
This adds SupportRequestSimplifyAggref to allow pg_proc.prosupportfunctions to receive an Aggref and allow them to determine if there is away that the Aggref call can be optimized.Also added is a support function to allow transformation of COUNT(ANY)into COUNT(*). This is possible to do when the given "ANY" cannot beNULL and also that there are no ORDER BY / DISTINCT clauses within theAggref. This is a useful transformation to do as it is common thatpeople write COUNT(1), which until now has added unneeded overhead.When counting a NOT NULL column. The overheads can be worse as thatmight mean deforming more of the tuple, which for large fact tables maybe many columns in.It may be possible to add prosupport functions for other aggregates. Wecould consider if ORDER BY could be dropped for some calls, e.g. theORDER BY is quite useless in MAX(c ORDER BY c).There is a little bit of passing fallout from adjustingexpr_is_nonnullable() to handle Const which results in a plan change inthe aggregates.out regression test. Previously, nothing was able todetermine that "One-Time Filter: (100 IS NOT NULL)" was always true,therefore useless to include in the plan.Author: David Rowley <dgrowleyml@gmail.com>Reviewed-by: Corey Huinker <corey.huinker@gmail.com>Reviewed-by: Matheus Alcantara <matheusssilv97@gmail.com>Discussion:https://postgr.es/m/CAApHDvqGcPTagXpKfH=CrmHBqALpziThJEDs_MrPqjKVeDF9wA@mail.gmail.com1 parentdbdc717 commit42473b3
File tree
9 files changed
+324
-36
lines changed- contrib/postgres_fdw/expected
- src
- backend
- optimizer
- plan
- util
- utils/adt
- include
- nodes
- optimizer
- test/regress
- expected
- sql
- tools/pgindent
9 files changed
+324
-36
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2975 | 2975 | | |
2976 | 2976 | | |
2977 | 2977 | | |
2978 | | - | |
| 2978 | + | |
2979 | 2979 | | |
2980 | | - | |
| 2980 | + | |
2981 | 2981 | | |
2982 | 2982 | | |
2983 | 2983 | | |
| |||
3073 | 3073 | | |
3074 | 3074 | | |
3075 | 3075 | | |
3076 | | - | |
3077 | | - | |
| 3076 | + | |
| 3077 | + | |
3078 | 3078 | | |
3079 | | - | |
| 3079 | + | |
3080 | 3080 | | |
3081 | | - | |
| 3081 | + | |
3082 | 3082 | | |
3083 | 3083 | | |
3084 | 3084 | | |
| |||
3379 | 3379 | | |
3380 | 3380 | | |
3381 | 3381 | | |
3382 | | - | |
3383 | | - | |
| 3382 | + | |
| 3383 | + | |
3384 | 3384 | | |
3385 | 3385 | | |
3386 | 3386 | | |
| |||
3391 | 3391 | | |
3392 | 3392 | | |
3393 | 3393 | | |
3394 | | - | |
| 3394 | + | |
3395 | 3395 | | |
3396 | | - | |
| 3396 | + | |
3397 | 3397 | | |
3398 | 3398 | | |
3399 | 3399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3413 | 3413 | | |
3414 | 3414 | | |
3415 | 3415 | | |
3416 | | - | |
3417 | | - | |
3418 | | - | |
3419 | | - | |
3420 | | - | |
3421 | | - | |
3422 | | - | |
3423 | | - | |
3424 | | - | |
3425 | | - | |
3426 | | - | |
3427 | | - | |
3428 | | - | |
3429 | | - | |
3430 | | - | |
3431 | | - | |
3432 | 3416 | | |
3433 | 3417 | | |
3434 | 3418 | | |
| |||
3465 | 3449 | | |
3466 | 3450 | | |
3467 | 3451 | | |
3468 | | - | |
| 3452 | + | |
3469 | 3453 | | |
3470 | 3454 | | |
3471 | 3455 | | |
| |||
3530 | 3514 | | |
3531 | 3515 | | |
3532 | 3516 | | |
3533 | | - | |
| 3517 | + | |
3534 | 3518 | | |
3535 | 3519 | | |
3536 | 3520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
| |||
2634 | 2636 | | |
2635 | 2637 | | |
2636 | 2638 | | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
2637 | 2642 | | |
2638 | 2643 | | |
2639 | 2644 | | |
| |||
4200 | 4205 | | |
4201 | 4206 | | |
4202 | 4207 | | |
| 4208 | + | |
| 4209 | + | |
| 4210 | + | |
| 4211 | + | |
| 4212 | + | |
| 4213 | + | |
| 4214 | + | |
| 4215 | + | |
| 4216 | + | |
| 4217 | + | |
| 4218 | + | |
| 4219 | + | |
| 4220 | + | |
| 4221 | + | |
| 4222 | + | |
| 4223 | + | |
| 4224 | + | |
| 4225 | + | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
| 4233 | + | |
| 4234 | + | |
| 4235 | + | |
| 4236 | + | |
| 4237 | + | |
| 4238 | + | |
| 4239 | + | |
| 4240 | + | |
| 4241 | + | |
| 4242 | + | |
| 4243 | + | |
| 4244 | + | |
| 4245 | + | |
| 4246 | + | |
| 4247 | + | |
| 4248 | + | |
| 4249 | + | |
| 4250 | + | |
| 4251 | + | |
4203 | 4252 | | |
4204 | 4253 | | |
4205 | 4254 | | |
| |||
4261 | 4310 | | |
4262 | 4311 | | |
4263 | 4312 | | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
4264 | 4337 | | |
4265 | 4338 | | |
4266 | 4339 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
811 | 811 | | |
812 | 812 | | |
813 | 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 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
814 | 861 | | |
815 | 862 | | |
816 | 863 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
74 | 99 | | |
75 | 100 | | |
76 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
150 | 153 | | |
151 | 154 | | |
152 | 155 | | |
| |||
0 commit comments
Comments
(0)