forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit959b38d
committed
Invent --transaction-size option for pg_restore.
This patch allows pg_restore to wrap its commands into transactionblocks, somewhat like --single-transaction, except that we commitand start a new block after every N objects. Using this modewith a size limit of 1000 or so objects greatly reduces the numberof transactions consumed by the restore, while preventing anyone transaction from taking enough locks to overrun the receivingserver's shared lock table.(A value of 1000 works well with the default lock table size ofaround 6400 locks. Higher --transaction-size values can be usedif one has increased the receiving server's lock table size.)Excessive consumption of XIDs has been reported as a problem forpg_upgrade in particular, but it could be bad for any restore; and thechange also reduces the number of fsyncs and amount of WAL generated,so it should provide speed benefits too.This patch does not try to make parallel workers batch the SQLcommands they issue. The trouble with doing that is that otherworkers may need to see the objects a worker creates right away.Possibly this can be improved later.In this patch I have hard-wired pg_upgrade to use a transaction sizeof 1000 divided by the number of parallel restore jobs allowed(without that, we'd still be at risk of overrunning the shared locktable). Perhaps there would be value in adding another pg_upgradeoption to allow user control of that, but I'm unsure that it's worththe trouble; I think few users would use it, and any who did would seenot that much benefit compared to the default.Patch by me, but the original idea to batch SQL commands duringrestore is due to Robins Tharakan.Discussion:https://postgr.es/m/a9f9376f1c3343a6bb319dce294e20ac@EX13D05UWC001.ant.amazon.com1 parenta45c78e commit959b38d
File tree
7 files changed
+220
-8
lines changed- doc/src/sgml/ref
- src/bin
- pg_dump
- pg_upgrade
7 files changed
+220
-8
lines changedLines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
789 | 813 |
| |
790 | 814 |
| |
791 | 815 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
149 | 149 |
| |
150 | 150 |
| |
151 | 151 |
| |
152 |
| - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
153 | 155 |
| |
154 | 156 |
| |
155 | 157 |
| |
|
Lines changed: 133 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
502 | 502 |
| |
503 | 503 |
| |
504 | 504 |
| |
| 505 | + | |
| 506 | + | |
505 | 507 |
| |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
506 | 527 |
| |
507 | 528 |
| |
508 | 529 |
| |
| |||
628 | 649 |
| |
629 | 650 |
| |
630 | 651 |
| |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
631 | 679 |
| |
632 | 680 |
| |
633 | 681 |
| |
| |||
724 | 772 |
| |
725 | 773 |
| |
726 | 774 |
| |
727 |
| - | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
728 | 780 |
| |
729 | 781 |
| |
730 | 782 |
| |
| |||
785 | 837 |
| |
786 | 838 |
| |
787 | 839 |
| |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
788 | 859 |
| |
789 | 860 |
| |
790 | 861 |
| |
| |||
835 | 906 |
| |
836 | 907 |
| |
837 | 908 |
| |
838 |
| - | |
| 909 | + | |
| 910 | + | |
839 | 911 |
| |
840 |
| - | |
841 |
| - | |
| 912 | + | |
842 | 913 |
| |
843 | 914 |
| |
844 | 915 |
| |
| |||
964 | 1035 |
| |
965 | 1036 |
| |
966 | 1037 |
| |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
967 | 1057 |
| |
968 | 1058 |
| |
969 | 1059 |
| |
| |||
1310 | 1400 |
| |
1311 | 1401 |
| |
1312 | 1402 |
| |
1313 |
| - | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
1314 | 1409 |
| |
1315 | 1410 |
| |
1316 | 1411 |
| |
| |||
1329 | 1424 |
| |
1330 | 1425 |
| |
1331 | 1426 |
| |
1332 |
| - | |
| 1427 | + | |
1333 | 1428 |
| |
1334 | 1429 |
| |
1335 | 1430 |
| |
| |||
3171 | 3266 |
| |
3172 | 3267 |
| |
3173 | 3268 |
| |
| 3269 | + | |
| 3270 | + | |
| 3271 | + | |
| 3272 | + | |
| 3273 | + | |
| 3274 | + | |
| 3275 | + | |
| 3276 | + | |
| 3277 | + | |
| 3278 | + | |
| 3279 | + | |
| 3280 | + | |
| 3281 | + | |
3174 | 3282 |
| |
3175 | 3283 |
| |
3176 | 3284 |
| |
| |||
4043 | 4151 |
| |
4044 | 4152 |
| |
4045 | 4153 |
| |
| 4154 | + | |
| 4155 | + | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
| 4161 | + | |
4046 | 4162 |
| |
4047 | 4163 |
| |
4048 | 4164 |
| |
| |||
4782 | 4898 |
| |
4783 | 4899 |
| |
4784 | 4900 |
| |
| 4901 | + | |
| 4902 | + | |
| 4903 | + | |
| 4904 | + | |
4785 | 4905 |
| |
4786 | 4906 |
| |
4787 | 4907 |
| |
| |||
4803 | 4923 |
| |
4804 | 4924 |
| |
4805 | 4925 |
| |
| 4926 | + | |
| 4927 | + | |
| 4928 | + | |
| 4929 | + | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
4806 | 4933 |
| |
4807 | 4934 |
| |
4808 | 4935 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
324 | 324 |
| |
325 | 325 |
| |
326 | 326 |
| |
| 327 | + | |
| 328 | + | |
| 329 | + | |
327 | 330 |
| |
328 | 331 |
| |
329 | 332 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
554 | 554 |
| |
555 | 555 |
| |
556 | 556 |
| |
| 557 | + | |
557 | 558 |
| |
558 | 559 |
| |
559 | 560 |
| |
| |||
562 | 563 |
| |
563 | 564 |
| |
564 | 565 |
| |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
565 | 583 |
| |
566 | 584 |
| |
567 | 585 |
| |
|
Lines changed: 14 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
120 | 120 |
| |
121 | 121 |
| |
122 | 122 |
| |
| 123 | + | |
123 | 124 |
| |
124 | 125 |
| |
125 | 126 |
| |
| |||
289 | 290 |
| |
290 | 291 |
| |
291 | 292 |
| |
292 |
| - | |
| 293 | + | |
293 | 294 |
| |
294 | 295 |
| |
295 | 296 |
| |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
296 | 305 |
| |
297 | 306 |
| |
298 | 307 |
| |
| |||
337 | 346 |
| |
338 | 347 |
| |
339 | 348 |
| |
| 349 | + | |
| 350 | + | |
| 351 | + | |
340 | 352 |
| |
341 | 353 |
| |
342 | 354 |
| |
| |||
484 | 496 |
| |
485 | 497 |
| |
486 | 498 |
| |
| 499 | + | |
487 | 500 |
| |
488 | 501 |
| |
489 | 502 |
| |
|
0 commit comments
Comments
(0)