Commit 2ac93a8
pg_dump: Retrieve attribute statistics in batches.
Currently, pg_dump gathers attribute statistics with a query per
relation, which can cause pg_dump to take significantly longer,
especially when there are many tables. This commit improves
matters by gathering attribute statistics for 64 relations at a
time. Some simple testing showed this was the ideal batch size,
but performance may vary depending on workload. This change
increases the memory usage of pg_dump a bit, but that isn't
expected to be too egregious and is arguably well worth the
trade-off.
Our lookahead code for determining the next batch of relations for
which to gather attribute statistics is simple: we walk the TOC
sequentially looking for eligible entries. However, the assumption
that we will dump all such entries in this order doesn't hold up
for dump formats that use RestoreArchive(). This is because
RestoreArchive() does multiple passes through the TOC and
selectively dumps certain entries each time. This is particularly
troublesome for index stats and a subset of matview stats; both are
in SECTION_POST_DATA, but matview stats that depend on matview data
are dumped in RESTORE_PASS_POST_ACL, while all other statistics
data is dumped in RESTORE_PASS_MAIN. To deal with this, this
commit moves all statistics data entries in SECTION_POST_DATA to
RESTORE_PASS_POST_ACL, which ensures that we always dump statistics
data entries in TOC order. One convenient side effect of this
change is that we can revert a decent chunk of commit a0a4601.
Author: Corey Huinker <[email protected]>
Co-authored-by: Nathan Bossart <[email protected]>
Reviewed-by: Jeff Davis <[email protected]>
Discussion: https://postgr.es/m/CADkLM%3Dc%2Br05srPy9w%2B-%2BnbmLEo15dKXYQ03Q_xyK%2BriJerigLQ%40mail.gmail.com1 parent 6a824d9 commit 2ac93a8
3 files changed
+155
-52
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
288 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
289 | 292 | | |
290 | 293 | | |
291 | 294 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
| 105 | + | |
107 | 106 | | |
108 | 107 | | |
109 | 108 | | |
| |||
749 | 748 | | |
750 | 749 | | |
751 | 750 | | |
752 | | - | |
| 751 | + | |
753 | 752 | | |
754 | 753 | | |
755 | 754 | | |
| |||
768 | 767 | | |
769 | 768 | | |
770 | 769 | | |
771 | | - | |
| 770 | + | |
772 | 771 | | |
773 | 772 | | |
774 | 773 | | |
| |||
778 | 777 | | |
779 | 778 | | |
780 | 779 | | |
781 | | - | |
| 780 | + | |
782 | 781 | | |
783 | 782 | | |
784 | 783 | | |
| |||
2650 | 2649 | | |
2651 | 2650 | | |
2652 | 2651 | | |
2653 | | - | |
| 2652 | + | |
2654 | 2653 | | |
2655 | 2654 | | |
2656 | 2655 | | |
| |||
3256 | 3255 | | |
3257 | 3256 | | |
3258 | 3257 | | |
3259 | | - | |
| 3258 | + | |
3260 | 3259 | | |
3261 | 3260 | | |
3262 | 3261 | | |
| |||
3279 | 3278 | | |
3280 | 3279 | | |
3281 | 3280 | | |
3282 | | - | |
| 3281 | + | |
| 3282 | + | |
| 3283 | + | |
| 3284 | + | |
| 3285 | + | |
| 3286 | + | |
| 3287 | + | |
3283 | 3288 | | |
3284 | | - | |
3285 | | - | |
3286 | | - | |
3287 | | - | |
3288 | | - | |
3289 | | - | |
3290 | | - | |
3291 | | - | |
3292 | | - | |
3293 | | - | |
3294 | | - | |
3295 | | - | |
3296 | | - | |
3297 | | - | |
3298 | | - | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
3299 | 3292 | | |
3300 | 3293 | | |
3301 | 3294 | | |
| |||
3945 | 3938 | | |
3946 | 3939 | | |
3947 | 3940 | | |
3948 | | - | |
| 3941 | + | |
3949 | 3942 | | |
3950 | 3943 | | |
3951 | 3944 | | |
| |||
4343 | 4336 | | |
4344 | 4337 | | |
4345 | 4338 | | |
4346 | | - | |
| 4339 | + | |
4347 | 4340 | | |
4348 | 4341 | | |
4349 | 4342 | | |
| |||
4425 | 4418 | | |
4426 | 4419 | | |
4427 | 4420 | | |
4428 | | - | |
| 4421 | + | |
4429 | 4422 | | |
4430 | 4423 | | |
4431 | 4424 | | |
| |||
4474 | 4467 | | |
4475 | 4468 | | |
4476 | 4469 | | |
4477 | | - | |
| 4470 | + | |
4478 | 4471 | | |
4479 | 4472 | | |
4480 | 4473 | | |
| |||
4645 | 4638 | | |
4646 | 4639 | | |
4647 | 4640 | | |
4648 | | - | |
4649 | | - | |
| 4641 | + | |
4650 | 4642 | | |
4651 | 4643 | | |
4652 | 4644 | | |
| |||
4659 | 4651 | | |
4660 | 4652 | | |
4661 | 4653 | | |
4662 | | - | |
| 4654 | + | |
4663 | 4655 | | |
4664 | 4656 | | |
4665 | 4657 | | |
| |||
5053 | 5045 | | |
5054 | 5046 | | |
5055 | 5047 | | |
5056 | | - | |
| 5048 | + | |
5057 | 5049 | | |
5058 | 5050 | | |
5059 | 5051 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
212 | 215 | | |
213 | 216 | | |
214 | 217 | | |
| |||
10553 | 10556 | | |
10554 | 10557 | | |
10555 | 10558 | | |
| 10559 | + | |
| 10560 | + | |
| 10561 | + | |
| 10562 | + | |
| 10563 | + | |
| 10564 | + | |
| 10565 | + | |
| 10566 | + | |
| 10567 | + | |
| 10568 | + | |
| 10569 | + | |
| 10570 | + | |
| 10571 | + | |
| 10572 | + | |
| 10573 | + | |
| 10574 | + | |
| 10575 | + | |
| 10576 | + | |
| 10577 | + | |
| 10578 | + | |
| 10579 | + | |
| 10580 | + | |
| 10581 | + | |
| 10582 | + | |
| 10583 | + | |
| 10584 | + | |
| 10585 | + | |
| 10586 | + | |
| 10587 | + | |
| 10588 | + | |
| 10589 | + | |
| 10590 | + | |
| 10591 | + | |
| 10592 | + | |
| 10593 | + | |
| 10594 | + | |
| 10595 | + | |
| 10596 | + | |
| 10597 | + | |
| 10598 | + | |
| 10599 | + | |
| 10600 | + | |
| 10601 | + | |
| 10602 | + | |
| 10603 | + | |
| 10604 | + | |
| 10605 | + | |
| 10606 | + | |
| 10607 | + | |
| 10608 | + | |
| 10609 | + | |
| 10610 | + | |
| 10611 | + | |
| 10612 | + | |
| 10613 | + | |
| 10614 | + | |
| 10615 | + | |
| 10616 | + | |
| 10617 | + | |
| 10618 | + | |
| 10619 | + | |
| 10620 | + | |
| 10621 | + | |
| 10622 | + | |
| 10623 | + | |
| 10624 | + | |
| 10625 | + | |
| 10626 | + | |
| 10627 | + | |
| 10628 | + | |
| 10629 | + | |
| 10630 | + | |
10556 | 10631 | | |
10557 | 10632 | | |
10558 | 10633 | | |
| |||
10561 | 10636 | | |
10562 | 10637 | | |
10563 | 10638 | | |
10564 | | - | |
| 10639 | + | |
10565 | 10640 | | |
10566 | 10641 | | |
10567 | 10642 | | |
10568 | | - | |
| 10643 | + | |
| 10644 | + | |
10569 | 10645 | | |
10570 | 10646 | | |
10571 | 10647 | | |
| 10648 | + | |
| 10649 | + | |
10572 | 10650 | | |
10573 | 10651 | | |
10574 | 10652 | | |
| |||
10584 | 10662 | | |
10585 | 10663 | | |
10586 | 10664 | | |
| 10665 | + | |
| 10666 | + | |
| 10667 | + | |
| 10668 | + | |
| 10669 | + | |
| 10670 | + | |
| 10671 | + | |
| 10672 | + | |
| 10673 | + | |
| 10674 | + | |
| 10675 | + | |
| 10676 | + | |
| 10677 | + | |
| 10678 | + | |
| 10679 | + | |
| 10680 | + | |
| 10681 | + | |
10587 | 10682 | | |
10588 | 10683 | | |
10589 | 10684 | | |
10590 | 10685 | | |
10591 | 10686 | | |
10592 | | - | |
10593 | | - | |
| 10687 | + | |
| 10688 | + | |
10594 | 10689 | | |
10595 | 10690 | | |
10596 | 10691 | | |
| |||
10608 | 10703 | | |
10609 | 10704 | | |
10610 | 10705 | | |
| 10706 | + | |
| 10707 | + | |
| 10708 | + | |
| 10709 | + | |
| 10710 | + | |
| 10711 | + | |
| 10712 | + | |
| 10713 | + | |
10611 | 10714 | | |
10612 | 10715 | | |
10613 | | - | |
10614 | | - | |
10615 | | - | |
| 10716 | + | |
| 10717 | + | |
| 10718 | + | |
| 10719 | + | |
| 10720 | + | |
10616 | 10721 | | |
10617 | 10722 | | |
10618 | 10723 | | |
| |||
10642 | 10747 | | |
10643 | 10748 | | |
10644 | 10749 | | |
| 10750 | + | |
| 10751 | + | |
| 10752 | + | |
| 10753 | + | |
| 10754 | + | |
| 10755 | + | |
| 10756 | + | |
10645 | 10757 | | |
10646 | | - | |
10647 | | - | |
10648 | | - | |
10649 | | - | |
10650 | | - | |
10651 | | - | |
10652 | | - | |
10653 | | - | |
10654 | | - | |
| 10758 | + | |
| 10759 | + | |
10655 | 10760 | | |
10656 | 10761 | | |
10657 | 10762 | | |
| |||
10669 | 10774 | | |
10670 | 10775 | | |
10671 | 10776 | | |
10672 | | - | |
| 10777 | + | |
10673 | 10778 | | |
10674 | 10779 | | |
10675 | 10780 | | |
| 10781 | + | |
| 10782 | + | |
| 10783 | + | |
| 10784 | + | |
| 10785 | + | |
10676 | 10786 | | |
10677 | 10787 | | |
10678 | 10788 | | |
| |||
10762 | 10872 | | |
10763 | 10873 | | |
10764 | 10874 | | |
10765 | | - | |
10766 | | - | |
10767 | 10875 | | |
10768 | 10876 | | |
10769 | 10877 | | |
| |||
0 commit comments