Commit 364509a
committed
pg_upgrade: Retrieve subscription count more efficiently.
Presently, pg_upgrade obtains the number of subscriptions in the
to-be-upgraded cluster by first querying pg_subscription in every
database for the number of subscriptions in only that database.
Then, in count_old_cluster_subscriptions(), it adds all the values
collected in the first step. This is expensive, especially when
there are many databases.
Fortunately, there is a better way to retrieve the subscription
count. Since pg_subscription is a shared catalog, we only need to
connect to a single database and query it once. This commit
modifies pg_upgrade to use that approach, which also allows us to
trim several lines of code. In passing, move the call to
get_db_subscription_count(), which has been renamed to
get_subscription_count(), from get_db_rel_and_slot_infos() to the
dedicated >= v17 section in check_and_dump_old_cluster().
We may be able to make similar improvements to
get_old_cluster_logical_slot_infos(), but that is left as a future
exercise.
Reviewed-by: Michael Paquier, Amit Kapila
Discussion: https://postgr.es/m/ZprQJv_TxccN3tkr%40nathan
Backpatch-through: 171 parent 9f21482 commit 364509a
3 files changed
+15
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
| 612 | + | |
| 613 | + | |
613 | 614 | | |
| 615 | + | |
614 | 616 | | |
615 | 617 | | |
616 | 618 | | |
| |||
1797 | 1799 | | |
1798 | 1800 | | |
1799 | 1801 | | |
1800 | | - | |
1801 | 1802 | | |
1802 | 1803 | | |
1803 | 1804 | | |
1804 | 1805 | | |
1805 | 1806 | | |
1806 | 1807 | | |
1807 | | - | |
1808 | | - | |
1809 | 1808 | | |
1810 | | - | |
| 1809 | + | |
1811 | 1810 | | |
1812 | 1811 | | |
1813 | 1812 | | |
| |||
1821 | 1820 | | |
1822 | 1821 | | |
1823 | 1822 | | |
1824 | | - | |
| 1823 | + | |
1825 | 1824 | | |
1826 | 1825 | | |
1827 | | - | |
| 1826 | + | |
1828 | 1827 | | |
1829 | 1828 | | |
1830 | 1829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | 295 | | |
301 | | - | |
302 | 296 | | |
303 | | - | |
304 | | - | |
305 | 297 | | |
306 | 298 | | |
307 | 299 | | |
| |||
748 | 740 | | |
749 | 741 | | |
750 | 742 | | |
751 | | - | |
752 | | - | |
753 | | - | |
| 743 | + | |
754 | 744 | | |
755 | | - | |
756 | | - | |
757 | | - | |
| 745 | + | |
758 | 746 | | |
759 | | - | |
760 | | - | |
| 747 | + | |
| 748 | + | |
761 | 749 | | |
762 | 750 | | |
763 | 751 | | |
764 | 752 | | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
| 753 | + | |
770 | 754 | | |
771 | | - | |
772 | | - | |
773 | | - | |
| 755 | + | |
| 756 | + | |
774 | 757 | | |
775 | 758 | | |
776 | 759 | | |
777 | 760 | | |
778 | 761 | | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
792 | | - | |
793 | | - | |
794 | | - | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
799 | 762 | | |
800 | 763 | | |
801 | 764 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
200 | | - | |
201 | 200 | | |
202 | 201 | | |
203 | 202 | | |
| |||
296 | 295 | | |
297 | 296 | | |
298 | 297 | | |
| 298 | + | |
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
| 433 | + | |
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| |||
0 commit comments