forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit20b9fa3
committed
Build inherited extended stats on partitioned tables
Commit859b300 disabled building of extended stats for inheritancetrees, to prevent updating the same catalog row twice. While thatresolved the issue, it also means there are no extended stats fordeclaratively partitioned tables, because there are no data in thenon-leaf relations.That also means declaratively partitioned tables were not affected bythe issue859b300 addressed, which means this is a regressionaffecting queries that calculate estimates for the whole inheritancetree as a whole (which includes e.g. GROUP BY queries).But because partitioned tables are empty, we can invert the conditionand build statistics only for the case with inheritance, without losinganything. And we can consider them when calculating estimates.It may be necessary to run ANALYZE on partitioned tables, to collectproper statistics. For declarative partitioning there should no priorstatistics, and it might take time before autoanalyze is triggered. Fortables partitioned by inheritance the statistics may include data fromchild relations (if built859b300), contradicting the current code.Report and patch by Justin Pryzby, minor fixes and cleanup by me.Backpatch all the way back to PostgreSQL 10, where extended statisticswere introduced (same as859b300).Author: Justin PryzbyReported-by: Justin PryzbyBackpatch-through: 10Discussion:https://postgr.es/m/20210923212624.GI831%40telsasoft.com1 parent74527c3 commit20b9fa3
File tree
6 files changed
+77
-19
lines changed- src
- backend
- commands
- statistics
- utils/adt
- test/regress
- expected
- sql
6 files changed
+77
-19
lines changedLines changed: 17 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
549 | 549 |
| |
550 | 550 |
| |
551 | 551 |
| |
| 552 | + | |
552 | 553 |
| |
553 | 554 |
| |
554 | 555 |
| |
| |||
612 | 613 |
| |
613 | 614 |
| |
614 | 615 |
| |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
615 | 631 |
| |
616 | 632 |
| |
617 | 633 |
| |
618 | 634 |
| |
619 | 635 |
| |
620 | 636 |
| |
621 |
| - | |
| 637 | + | |
622 | 638 |
| |
623 | 639 |
| |
624 | 640 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1418 | 1418 |
| |
1419 | 1419 |
| |
1420 | 1420 |
| |
1421 |
| - | |
1422 |
| - | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
1423 | 1426 |
| |
1424 |
| - | |
| 1427 | + | |
1425 | 1428 |
| |
1426 | 1429 |
| |
1427 | 1430 |
| |
|
Lines changed: 6 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1698 | 1698 |
| |
1699 | 1699 |
| |
1700 | 1700 |
| |
1701 |
| - | |
1702 |
| - | |
| 1701 | + | |
| 1702 | + | |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
1703 | 1706 |
| |
1704 |
| - | |
| 1707 | + | |
1705 | 1708 |
| |
1706 | 1709 |
| |
1707 | 1710 |
| |
|
Lines changed: 19 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3913 | 3913 |
| |
3914 | 3914 |
| |
3915 | 3915 |
| |
3916 |
| - | |
3917 |
| - | |
3918 |
| - | |
3919 |
| - | |
3920 |
| - | |
3921 |
| - | |
3922 |
| - | |
3923 |
| - | |
| 3916 | + | |
3924 | 3917 |
| |
3925 | 3918 |
| |
3926 | 3919 |
| |
3927 | 3920 |
| |
3928 | 3921 |
| |
| 3922 | + | |
| 3923 | + | |
| 3924 | + | |
| 3925 | + | |
| 3926 | + | |
| 3927 | + | |
| 3928 | + | |
| 3929 | + | |
| 3930 | + | |
| 3931 | + | |
| 3932 | + | |
3929 | 3933 |
| |
3930 | 3934 |
| |
3931 | 3935 |
| |
| |||
5242 | 5246 |
| |
5243 | 5247 |
| |
5244 | 5248 |
| |
5245 |
| - | |
5246 |
| - | |
5247 |
| - | |
| 5249 | + | |
| 5250 | + | |
| 5251 | + | |
| 5252 | + | |
| 5253 | + | |
| 5254 | + | |
5248 | 5255 |
| |
5249 |
| - | |
| 5256 | + | |
5250 | 5257 |
| |
5251 | 5258 |
| |
5252 | 5259 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
217 | 217 |
| |
218 | 218 |
| |
219 | 219 |
| |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
220 | 239 |
| |
221 | 240 |
| |
222 | 241 |
| |
|
Lines changed: 10 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
134 | 134 |
| |
135 | 135 |
| |
136 | 136 |
| |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
137 | 147 |
| |
138 | 148 |
| |
139 | 149 |
| |
|
0 commit comments
Comments
(0)