forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit851a26e
committed
While vacuuming a large table, update upper-level FSM data every so often.
VACUUM updates leaf-level FSM entries immediately after cleaning thecorresponding heap blocks. fsmpage.c updates the intra-page search treeson the leaf-level FSM pages when this happens, but it does not touch theupper-level FSM pages, so that the released space might not actually befindable by searchers. Previously, updating the upper-level pages happenedonly at the conclusion of the VACUUM run, in a single FreeSpaceMapVacuum()call. This is bad because the VACUUM might get canceled before everreaching that point, so that from the point of view of searchers no spacehas been freed at all, leading to table bloat.We can improve matters by updating the upper pages immediately after eachcycle of index-cleaning and heap-cleaning, processing just the FSM pagescorresponding to the range of heap blocks we have now fully cleaned.This adds a small amount of extra work, since the FSM pages leading downto each range boundary will be touched twice, but it's pretty negligiblecompared to everything else going on in a large VACUUM.If there are no indexes, VACUUM doesn't work in cycles but just cleanseach heap page on first visit. In that case we just arbitrarily updateupper FSM pages after each 8GB of heap. That maintains the goal of notletting all this work slide until the very end, and it doesn't seem worthexpending extra complexity on a case that so seldom occurs in practice.In either case, the FSM is fully up to date before any attempt is madeto truncate the relation, so that the most likely scenario for VACUUMcancellation no longer results in out-of-date upper FSM pages. Whenwe do successfully truncate, adjusting the FSM to reflect that is nowfully handled within FreeSpaceMapTruncateRel.Claudio Freire, reviewed by Masahiko Sawada and Jing Wang, some additionaltweaks by meDiscussion:https://postgr.es/m/CAGTBQpYR0uJCNTt3M5GOzBRHo+-GccNO1nCaQ8yEJmZKSW5q1A@mail.gmail.com1 parentc0cbe00 commit851a26e
File tree
4 files changed
+141
-23
lines changed- src
- backend
- commands
- storage/freespace
- include/storage
4 files changed
+141
-23
lines changedLines changed: 39 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
87 | 96 |
| |
88 | 97 |
| |
89 | 98 |
| |
| |||
285 | 294 |
| |
286 | 295 |
| |
287 | 296 |
| |
288 |
| - | |
289 |
| - | |
290 |
| - | |
291 | 297 |
| |
292 | 298 |
| |
293 | 299 |
| |
| |||
465 | 471 |
| |
466 | 472 |
| |
467 | 473 |
| |
468 |
| - | |
| 474 | + | |
| 475 | + | |
469 | 476 |
| |
470 | 477 |
| |
471 | 478 |
| |
| |||
501 | 508 |
| |
502 | 509 |
| |
503 | 510 |
| |
| 511 | + | |
504 | 512 |
| |
505 | 513 |
| |
506 | 514 |
| |
| |||
752 | 760 |
| |
753 | 761 |
| |
754 | 762 |
| |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
755 | 770 |
| |
756 | 771 |
| |
757 | 772 |
| |
| |||
1200 | 1215 |
| |
1201 | 1216 |
| |
1202 | 1217 |
| |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1203 | 1231 |
| |
1204 | 1232 |
| |
1205 | 1233 |
| |
| |||
1368 | 1396 |
| |
1369 | 1397 |
| |
1370 | 1398 |
| |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1371 | 1406 |
| |
1372 | 1407 |
| |
1373 | 1408 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
180 | 180 |
| |
181 | 181 |
| |
182 | 182 |
| |
183 |
| - | |
| 183 | + | |
184 | 184 |
| |
185 |
| - | |
186 |
| - | |
187 |
| - | |
188 |
| - | |
189 |
| - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
190 | 190 |
| |
191 | 191 |
| |
192 | 192 |
| |
|
Lines changed: 94 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
111 |
| - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
112 | 114 |
| |
113 | 115 |
| |
114 | 116 |
| |
| |||
370 | 372 |
| |
371 | 373 |
| |
372 | 374 |
| |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
373 | 382 |
| |
374 | 383 |
| |
375 | 384 |
| |
376 |
| - | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
377 | 389 |
| |
378 | 390 |
| |
379 | 391 |
| |
380 | 392 |
| |
381 | 393 |
| |
382 | 394 |
| |
383 |
| - | |
384 |
| - | |
385 |
| - | |
386 |
| - | |
387 |
| - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
388 | 417 |
| |
389 | 418 |
| |
390 | 419 |
| |
| |||
783 | 812 |
| |
784 | 813 |
| |
785 | 814 |
| |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
786 | 825 |
| |
787 | 826 |
| |
788 |
| - | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
789 | 830 |
| |
790 | 831 |
| |
791 | 832 |
| |
| |||
804 | 845 |
| |
805 | 846 |
| |
806 | 847 |
| |
807 |
| - | |
808 |
| - | |
| 848 | + | |
| 849 | + | |
809 | 850 |
| |
810 | 851 |
| |
811 | 852 |
| |
812 |
| - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
813 | 860 |
| |
814 | 861 |
| |
815 |
| - | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
816 | 894 |
| |
817 | 895 |
| |
818 | 896 |
| |
819 | 897 |
| |
820 | 898 |
| |
821 | 899 |
| |
822 | 900 |
| |
823 |
| - | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
824 | 904 |
| |
825 | 905 |
| |
826 | 906 |
| |
| |||
835 | 915 |
| |
836 | 916 |
| |
837 | 917 |
| |
| 918 | + | |
838 | 919 |
| |
839 | 920 |
| |
840 | 921 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| 35 | + | |
| 36 | + | |
35 | 37 |
| |
36 | 38 |
| |
37 | 39 |
| |
|
0 commit comments
Comments
(0)