forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitd6ad34f

Amit Kapila
Optimize DropRelFileNodeBuffers() for recovery.
The recovery path of DropRelFileNodeBuffers() is optimized so thatscanning of the whole buffer pool can be avoided when the number ofblocks to be truncated in a relation is below a certain threshold. Forsuch cases, we find the buffers by doing lookups in BufMapping table.This improves the performance by more than 100 times in many caseswhen several small tables (tested with 1000 relations) are truncatedand where the server is configured with a large value of sharedbuffers (greater than equal to 100GB).This optimization helps cases (a) when vacuum or autovacuum truncated offany of the empty pages at the end of a relation, or (b) when the relation istruncated in the same transaction in which it was created.This commit introduces a new API smgrnblocks_cached which returns a cachedvalue for the number of blocks in a relation fork. This helps us to determinethe exact size of relation which is required to apply this optimization. Theexact size is required to ensure that we don't leave any buffer for therelation being dropped as otherwise the background writer or checkpointercan lead to a PANIC error while flushing buffers corresponding to files thatdon't exist.Author: Kirk Jamison based on ideas by Amit KapilaReviewed-by: Kyotaro Horiguchi, Takayuki Tsunakawa, and Amit KapilaTested-By: Haiying TangDiscussion:https://postgr.es/m/OSBPR01MB3207DCA7EC725FDD661B3EDAEF660@OSBPR01MB3207.jpnprd01.prod.outlook.com1 parent9a4c0e3 commitd6ad34f
4 files changed
+154
-15
lines changedLines changed: 128 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
73 | 81 |
| |
74 | 82 |
| |
75 | 83 |
| |
| |||
473 | 481 |
| |
474 | 482 |
| |
475 | 483 |
| |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
476 | 488 |
| |
477 | 489 |
| |
478 | 490 |
| |
| |||
2965 | 2977 |
| |
2966 | 2978 |
| |
2967 | 2979 |
| |
2968 |
| - | |
2969 |
| - | |
2970 |
| - | |
2971 |
| - | |
2972 |
| - | |
2973 | 2980 |
| |
2974 | 2981 |
| |
2975 | 2982 |
| |
2976 |
| - | |
| 2983 | + | |
2977 | 2984 |
| |
2978 | 2985 |
| |
2979 | 2986 |
| |
2980 | 2987 |
| |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
2981 | 2993 |
| |
2982 | 2994 |
| |
2983 | 2995 |
| |
| |||
2991 | 3003 |
| |
2992 | 3004 |
| |
2993 | 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 | + | |
2994 | 3056 |
| |
2995 | 3057 |
| |
2996 | 3058 |
| |
| |||
3133 | 3195 |
| |
3134 | 3196 |
| |
3135 | 3197 |
| |
| 3198 | + | |
| 3199 | + | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
| 3211 | + | |
| 3212 | + | |
| 3213 | + | |
| 3214 | + | |
| 3215 | + | |
| 3216 | + | |
| 3217 | + | |
| 3218 | + | |
| 3219 | + | |
| 3220 | + | |
| 3221 | + | |
| 3222 | + | |
| 3223 | + | |
| 3224 | + | |
| 3225 | + | |
| 3226 | + | |
| 3227 | + | |
| 3228 | + | |
| 3229 | + | |
| 3230 | + | |
| 3231 | + | |
| 3232 | + | |
| 3233 | + | |
| 3234 | + | |
| 3235 | + | |
| 3236 | + | |
| 3237 | + | |
| 3238 | + | |
| 3239 | + | |
| 3240 | + | |
| 3241 | + | |
| 3242 | + | |
| 3243 | + | |
| 3244 | + | |
| 3245 | + | |
| 3246 | + | |
| 3247 | + | |
| 3248 | + | |
| 3249 | + | |
| 3250 | + | |
| 3251 | + | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
| 3256 | + | |
3136 | 3257 |
| |
3137 | 3258 |
| |
3138 | 3259 |
| |
| |||
3245 | 3366 |
| |
3246 | 3367 |
| |
3247 | 3368 |
| |
3248 |
| - | |
3249 |
| - | |
| 3369 | + | |
3250 | 3370 |
| |
3251 | 3371 |
| |
3252 | 3372 |
| |
|
Lines changed: 24 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
549 | 549 |
| |
550 | 550 |
| |
551 | 551 |
| |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
552 | 574 |
| |
553 | 575 |
| |
554 | 576 |
| |
555 | 577 |
| |
556 | 578 |
| |
557 | 579 |
| |
558 | 580 |
| |
559 |
| - | |
560 |
| - | |
561 |
| - | |
562 |
| - | |
563 |
| - | |
| 581 | + | |
564 | 582 |
| |
565 | 583 |
| |
566 | 584 |
| |
| |||
582 | 600 |
| |
583 | 601 |
| |
584 | 602 |
| |
585 |
| - | |
| 603 | + | |
586 | 604 |
| |
587 | 605 |
| |
588 | 606 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
203 | 203 |
| |
204 | 204 |
| |
205 | 205 |
| |
206 |
| - | |
| 206 | + | |
207 | 207 |
| |
208 | 208 |
| |
209 | 209 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
99 | 99 |
| |
100 | 100 |
| |
101 | 101 |
| |
| 102 | + | |
102 | 103 |
| |
103 | 104 |
| |
104 | 105 |
| |
|
0 commit comments
Comments
(0)