forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitfbc0fe9

Richard Guo
Adjust tuples estimate for appendrels
In set_append_rel_size(), we currently set rel->tuples to rel->rowsfor an appendrel. Generally, rel->tuples is the raw number of tuplesin the relation and rel->rows is the estimated number of tuples afterthe relation's restriction clauses have been applied. Although anappendrel itself doesn't directly enforce any quals today, its childrelations may. Therefore, setting rel->tuples equal to rel->rows foran appendrel isn't always appropriate.Doing so can lead to issues in cost estimates in some cases. Forinstance, when estimating the number of distinct values from anappendrel, we would not be able to adjust the estimate based on therestriction selectivity.This patch addresses this by setting an appendrel's tuples to thetotal number of tuples accumulated from each live child, which betteraligns with reality.This is arguably a bug, but nobody has complained about that untilnow, so no back-patch.Author: Richard Guo <guofenglinux@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Reviewed-by: Alena Rybakina <a.rybakina@postgrespro.ru>Discussion:https://postgr.es/m/CAMbWs4_TG_+kVn6fjG-5GYzzukrNK57=g9eUo4gsrUG26OFawg@mail.gmail.com1 parenta7f9585 commitfbc0fe9
File tree
3 files changed
+64
-6
lines changed- src
- backend/optimizer/path
- test/regress
- expected
- sql
3 files changed
+64
-6
lines changedLines changed: 13 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
958 | 958 |
| |
959 | 959 |
| |
960 | 960 |
| |
| 961 | + | |
961 | 962 |
| |
962 | 963 |
| |
963 | 964 |
| |
| |||
983 | 984 |
| |
984 | 985 |
| |
985 | 986 |
| |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
986 | 996 |
| |
987 | 997 |
| |
988 | 998 |
| |
| |||
995 | 1005 |
| |
996 | 1006 |
| |
997 | 1007 |
| |
| 1008 | + | |
998 | 1009 |
| |
999 | 1010 |
| |
1000 | 1011 |
| |
| |||
1161 | 1172 |
| |
1162 | 1173 |
| |
1163 | 1174 |
| |
| 1175 | + | |
1164 | 1176 |
| |
1165 | 1177 |
| |
1166 | 1178 |
| |
| |||
1207 | 1219 |
| |
1208 | 1220 |
| |
1209 | 1221 |
| |
| 1222 | + | |
1210 | 1223 |
| |
1211 | 1224 |
| |
1212 | 1225 |
| |
1213 | 1226 |
| |
1214 | 1227 |
| |
1215 |
| - | |
1216 |
| - | |
1217 |
| - | |
1218 |
| - | |
1219 |
| - | |
1220 |
| - | |
1221 | 1228 |
| |
1222 | 1229 |
| |
1223 | 1230 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3666 | 3666 |
| |
3667 | 3667 |
| |
3668 | 3668 |
| |
| 3669 | + | |
| 3670 | + | |
| 3671 | + | |
| 3672 | + | |
| 3673 | + | |
| 3674 | + | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
| 3685 | + | |
| 3686 | + | |
| 3687 | + | |
| 3688 | + | |
| 3689 | + | |
| 3690 | + | |
| 3691 | + | |
| 3692 | + | |
| 3693 | + | |
| 3694 | + | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
| 3698 | + |
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1483 | 1483 |
| |
1484 | 1484 |
| |
1485 | 1485 |
| |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + |
0 commit comments
Comments
(0)