- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit9dd963a
committed
Recycle nbtree pages deleted during same VACUUM.
Maintain a simple array of metadata about pages that were deleted duringnbtree VACUUM's current btvacuumscan() call. Use this metadata at theend of btvacuumscan() to attempt to place newly deleted pages in the FSMwithout further delay. It might not yet be safe to place any of thepages in the FSM by then (they may not be deemed recyclable), but wehave little to lose and plenty to gain by trying. In practice there isa very good chance that this will work out when vacuuming largerindexes, where scanning the index naturally takes quite a while.This commit doesn't change the page recycling invariants; it merelyimproves the efficiency of page recycling within the confines of theexisting design. Recycle safety is a part of nbtree's implementation ofwhat Lanin & Shasha call "the drain technique". The design happens touse transaction IDs (they're stored in deleted pages), but that initself doesn't align the cutoff for recycle safety to any of theXID-based cutoffs used by VACUUM (e.g., OldestXmin). All that mattersis whether or not _other_ backends might be able to observe variousinconsistencies in the tree structure (that they cannot just detect andrecover from by moving right). Recycle safety is purely a question ofmaintaining the consistency (or the apparent consistency) of a physicaldata structure.Note that running a simple serial test case involving a large rangeDELETE followed by a VACUUM VERBOSE will probably show that any newlydeleted nbtree pages are not yet reusable/recyclable. This is expectedin the absence of even one concurrent XID assignment. It is an oldimplementation restriction. In practice it's unlikely to be the thingthat makes recycling remain unsafe, at least with larger indexes, whererecycling newly deleted pages during the same VACUUM actually matters.An important high-level goal of this commit (as well as related recentcommitse5d8a99 and9f3665f) is to make expensive deferred cleanupoperations in index AMs rare in general. If index vacuuming frequentlydepends on the next VACUUM operation finishing off work that the currentoperation started, then the general behavior of index vacuuming is hardto predict. This is relevant to ongoing work that adds a vacuumlazy.cmechanism to skip index vacuuming in certain cases. Anything that makesthe real world behavior of index vacuuming simpler and more linear willalso make top-down modeling in vacuumlazy.c more robust.Author: Peter Geoghegan <pg@bowt.ie>Reviewed-By: Masahiko Sawada <sawada.mshk@gmail.com>Discussion:https://postgr.es/m/CAH2-Wzk76_P=67iUscb1UN44-gyZL-KgpsXbSxq_bdcMa7Q+wQ@mail.gmail.com1 parent4d399a6 commit9dd963a
4 files changed
+260
-23
lines changedLines changed: 24 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
413 | 413 |
| |
414 | 414 |
| |
415 | 415 |
| |
416 |
| - | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
417 | 440 |
| |
418 | 441 |
| |
419 | 442 |
| |
|
Lines changed: 189 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| 35 | + | |
35 | 36 |
| |
| 37 | + | |
36 | 38 |
| |
37 | 39 |
| |
38 | 40 |
| |
| |||
57 | 59 |
| |
58 | 60 |
| |
59 | 61 |
| |
| 62 | + | |
| 63 | + | |
60 | 64 |
| |
61 | 65 |
| |
62 | 66 |
| |
| |||
209 | 213 |
| |
210 | 214 |
| |
211 | 215 |
| |
212 |
| - | |
213 |
| - | |
214 |
| - | |
215 |
| - | |
216 |
| - | |
217 |
| - | |
218 |
| - | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
219 | 219 |
| |
220 | 220 |
| |
221 | 221 |
| |
| |||
2729 | 2729 |
| |
2730 | 2730 |
| |
2731 | 2731 |
| |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
2732 | 2740 |
| |
2733 | 2741 |
| |
2734 | 2742 |
| |
| |||
2873 | 2881 |
| |
2874 | 2882 |
| |
2875 | 2883 |
| |
| 2884 | + | |
| 2885 | + | |
| 2886 | + | |
| 2887 | + | |
| 2888 | + | |
| 2889 | + | |
| 2890 | + | |
| 2891 | + | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + | |
| 2895 | + | |
| 2896 | + | |
| 2897 | + | |
| 2898 | + | |
| 2899 | + | |
| 2900 | + | |
| 2901 | + | |
| 2902 | + | |
| 2903 | + | |
| 2904 | + | |
| 2905 | + | |
| 2906 | + | |
| 2907 | + | |
| 2908 | + | |
| 2909 | + | |
| 2910 | + | |
| 2911 | + | |
| 2912 | + | |
| 2913 | + | |
| 2914 | + | |
| 2915 | + | |
| 2916 | + | |
| 2917 | + | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
| 2955 | + | |
| 2956 | + | |
| 2957 | + | |
| 2958 | + | |
| 2959 | + | |
| 2960 | + | |
| 2961 | + | |
| 2962 | + | |
| 2963 | + | |
| 2964 | + | |
| 2965 | + | |
| 2966 | + | |
| 2967 | + | |
| 2968 | + | |
| 2969 | + | |
| 2970 | + | |
| 2971 | + | |
| 2972 | + | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
| 2976 | + | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
| 2985 | + | |
| 2986 | + | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
| 2996 | + | |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
| 3008 | + | |
| 3009 | + | |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
| 3023 | + | |
| 3024 | + | |
| 3025 | + | |
| 3026 | + | |
| 3027 | + | |
| 3028 | + | |
| 3029 | + | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
| 3034 | + | |
| 3035 | + | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + | |
| 3039 | + | |
| 3040 | + | |
| 3041 | + | |
| 3042 | + | |
| 3043 | + | |
| 3044 | + | |
| 3045 | + | |
| 3046 | + | |
| 3047 | + | |
| 3048 | + | |
| 3049 | + | |
| 3050 | + | |
| 3051 | + | |
| 3052 | + | |
| 3053 | + | |
| 3054 | + | |
| 3055 | + | |
| 3056 | + | |
| 3057 | + |
Lines changed: 22 additions & 12 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
859 | 859 |
| |
860 | 860 |
| |
861 | 861 |
| |
862 |
| - | |
863 |
| - | |
864 |
| - | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
865 | 869 |
| |
866 | 870 |
| |
867 | 871 |
| |
| |||
937 | 941 |
| |
938 | 942 |
| |
939 | 943 |
| |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
940 | 952 |
| |
941 | 953 |
| |
942 | 954 |
| |
| |||
995 | 1007 |
| |
996 | 1008 |
| |
997 | 1009 |
| |
998 |
| - | |
999 |
| - | |
1000 |
| - | |
1001 |
| - | |
1002 |
| - | |
1003 |
| - | |
1004 |
| - | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
1005 | 1013 |
| |
1006 |
| - | |
1007 |
| - | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
1008 | 1017 |
| |
| 1018 | + | |
1009 | 1019 |
| |
1010 | 1020 |
| |
1011 | 1021 |
| |
|
Lines changed: 25 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
279 | 279 |
| |
280 | 280 |
| |
281 | 281 |
| |
282 |
| - | |
| 282 | + | |
| 283 | + | |
283 | 284 |
| |
284 | 285 |
| |
285 | 286 |
| |
| |||
305 | 306 |
| |
306 | 307 |
| |
307 | 308 |
| |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
308 | 313 |
| |
309 | 314 |
| |
310 | 315 |
| |
| |||
313 | 318 |
| |
314 | 319 |
| |
315 | 320 |
| |
316 |
| - | |
317 |
| - | |
| 321 | + | |
| 322 | + | |
318 | 323 |
| |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
319 | 330 |
| |
320 | 331 |
| |
321 | 332 |
| |
| |||
324 | 335 |
| |
325 | 336 |
| |
326 | 337 |
| |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
327 | 346 |
| |
328 | 347 |
| |
329 | 348 |
| |
| |||
1195 | 1214 |
| |
1196 | 1215 |
| |
1197 | 1216 |
| |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
1198 | 1220 |
| |
1199 | 1221 |
| |
1200 | 1222 |
| |
|
0 commit comments
Comments
(0)