- Notifications
You must be signed in to change notification settings - Fork28
Commitb07642d
committed
Trigger autovacuum based on number of INSERTs
Traditionally autovacuum has only ever invoked a worker based on theestimated number of dead tuples in a table and for anti-wraparoundpurposes. For the latter, with certain classes of tables such asinsert-only tables, anti-wraparound vacuums could be the first vacuum thatthe table ever receives. This could often lead to autovacuum workers beingbusy for extended periods of time due to having to potentially freezeevery page in the table. This could be particularly bad for very largetables. New clusters, or recently pg_restored clusters could suffer evenmore as many large tables may have the same relfrozenxid, which couldresult in large numbers of tables requiring an anti-wraparound vacuum allat once.Here we aim to reduce the work required by anti-wraparound and aggressivevacuums in general, by triggering autovacuum when the table has receivedenough INSERTs. This is controlled by adding two new GUCs and reloptions;autovacuum_vacuum_insert_threshold andautovacuum_vacuum_insert_scale_factor. These work exactly the same as theexisting scale factor and threshold controls, only base themselves off thenumber of inserts since the last vacuum, rather than the number of deadtuples. New controls were added rather than reusing the existingcontrols, to allow these new vacuums to be tuned independently and perhapseven completely disabled altogether, which can be done by settingautovacuum_vacuum_insert_threshold to -1.We make no attempt to skip index cleanup operations on these vacuums asthey may trigger for an insert-mostly table which continually doesn't haveenough dead tuples to trigger an autovacuum for the purpose of removingthose dead tuples. If we were to skip cleaning the indexes in this case,then it is possible for the index(es) to become bloated over time.There are additional benefits to triggering autovacuums based on inserts,as tables which never contain enough dead tuples to trigger an autovacuumare now more likely to receive a vacuum, which can mark more of the tableas "allvisible" and encourage the query planner to make use of Index OnlyScans.Currently, we still obey vacuum_freeze_min_age when triggering these newautovacuums based on INSERTs. For large insert-only tables, it may bebeneficial to lower the table's autovacuum_freeze_min_age so that tuplesare eligible to be frozen sooner. Here we've opted not to zero that forthese types of vacuums, since the table may just be insert-mostly and wemay otherwise freeze tuples that are still destined to be updated orremoved in the near future.There was some debate to what exactly the new scale factor and thresholdshould default to. For now, these are set to 0.2 and 1000, respectively.There may be some motivation to adjust these before the release.Author: Laurenz Albe, Darafei PraliaskouskiReviewed-by: Alvaro Herrera, Masahiko Sawada, Chris Travers, Andres Freund, Justin PryzbyDiscussion:https://postgr.es/m/CAC8Q8t%2Bj36G_bLF%3D%2B0iMo6jGNWnLnWb1tujXuJr-%2Bx8ZCCTqoQ%40mail.gmail.com1 parent9945ad6 commitb07642d
File tree
18 files changed
+230
-12
lines changed- doc/src/sgml
- ref
- src
- backend
- access/common
- catalog
- postmaster
- utils
- adt
- misc
- bin/psql
- include
- catalog
- postmaster
- utils
- test/regress/expected
18 files changed
+230
-12
lines changedLines changed: 43 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7313 | 7313 |
| |
7314 | 7314 |
| |
7315 | 7315 |
| |
| 7316 | + | |
| 7317 | + | |
| 7318 | + | |
| 7319 | + | |
| 7320 | + | |
| 7321 | + | |
| 7322 | + | |
| 7323 | + | |
| 7324 | + | |
| 7325 | + | |
| 7326 | + | |
| 7327 | + | |
| 7328 | + | |
| 7329 | + | |
| 7330 | + | |
| 7331 | + | |
| 7332 | + | |
| 7333 | + | |
| 7334 | + | |
| 7335 | + | |
| 7336 | + | |
| 7337 | + | |
7316 | 7338 |
| |
7317 | 7339 |
| |
7318 | 7340 |
| |
| |||
7354 | 7376 |
| |
7355 | 7377 |
| |
7356 | 7378 |
| |
| 7379 | + | |
| 7380 | + | |
| 7381 | + | |
| 7382 | + | |
| 7383 | + | |
| 7384 | + | |
| 7385 | + | |
| 7386 | + | |
| 7387 | + | |
| 7388 | + | |
| 7389 | + | |
| 7390 | + | |
| 7391 | + | |
| 7392 | + | |
| 7393 | + | |
| 7394 | + | |
| 7395 | + | |
| 7396 | + | |
| 7397 | + | |
| 7398 | + | |
| 7399 | + | |
7357 | 7400 |
| |
7358 | 7401 |
| |
7359 | 7402 |
| |
|
Lines changed: 27 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
777 | 777 |
| |
778 | 778 |
| |
779 | 779 |
| |
780 |
| - | |
781 |
| - | |
782 |
| - | |
783 |
| - | |
784 |
| - | |
785 |
| - | |
786 |
| - | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
787 | 807 |
| |
788 | 808 |
| |
789 | 809 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2861 | 2861 |
| |
2862 | 2862 |
| |
2863 | 2863 |
| |
| 2864 | + | |
| 2865 | + | |
| 2866 | + | |
| 2867 | + | |
| 2868 | + | |
2864 | 2869 |
| |
2865 | 2870 |
| |
2866 | 2871 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1475 | 1475 |
| |
1476 | 1476 |
| |
1477 | 1477 |
| |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
1478 | 1508 |
| |
1479 | 1509 |
| |
1480 | 1510 |
| |
|
Lines changed: 22 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
236 | 245 |
| |
237 | 246 |
| |
238 | 247 |
| |
| |||
398 | 407 |
| |
399 | 408 |
| |
400 | 409 |
| |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
401 | 419 |
| |
402 | 420 |
| |
403 | 421 |
| |
| |||
1514 | 1532 |
| |
1515 | 1533 |
| |
1516 | 1534 |
| |
| 1535 | + | |
| 1536 | + | |
1517 | 1537 |
| |
1518 | 1538 |
| |
1519 | 1539 |
| |
| |||
1538 | 1558 |
| |
1539 | 1559 |
| |
1540 | 1560 |
| |
| 1561 | + | |
| 1562 | + | |
1541 | 1563 |
| |
1542 | 1564 |
| |
1543 | 1565 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
573 | 573 |
| |
574 | 574 |
| |
575 | 575 |
| |
| 576 | + | |
576 | 577 |
| |
577 | 578 |
| |
578 | 579 |
| |
|
Lines changed: 27 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
117 | 117 |
| |
118 | 118 |
| |
119 | 119 |
| |
| 120 | + | |
| 121 | + | |
120 | 122 |
| |
121 | 123 |
| |
122 | 124 |
| |
| |||
2969 | 2971 |
| |
2970 | 2972 |
| |
2971 | 2973 |
| |
| 2974 | + | |
2972 | 2975 |
| |
2973 | 2976 |
| |
| 2977 | + | |
2974 | 2978 |
| |
2975 | 2979 |
| |
2976 | 2980 |
| |
2977 | 2981 |
| |
| 2982 | + | |
2978 | 2983 |
| |
2979 | 2984 |
| |
2980 | 2985 |
| |
2981 | 2986 |
| |
| 2987 | + | |
2982 | 2988 |
| |
2983 | 2989 |
| |
2984 | 2990 |
| |
| |||
3005 | 3011 |
| |
3006 | 3012 |
| |
3007 | 3013 |
| |
| 3014 | + | |
| 3015 | + | |
| 3016 | + | |
| 3017 | + | |
| 3018 | + | |
| 3019 | + | |
| 3020 | + | |
| 3021 | + | |
| 3022 | + | |
3008 | 3023 |
| |
3009 | 3024 |
| |
3010 | 3025 |
| |
| |||
3059 | 3074 |
| |
3060 | 3075 |
| |
3061 | 3076 |
| |
| 3077 | + | |
3062 | 3078 |
| |
3063 | 3079 |
| |
3064 | 3080 |
| |
| 3081 | + | |
3065 | 3082 |
| |
3066 | 3083 |
| |
3067 | 3084 |
| |
3068 | 3085 |
| |
3069 | 3086 |
| |
3070 | 3087 |
| |
3071 | 3088 |
| |
3072 |
| - | |
3073 |
| - | |
3074 |
| - | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
| 3095 | + | |
| 3096 | + | |
3075 | 3097 |
| |
3076 | 3098 |
| |
3077 |
| - | |
| 3099 | + | |
| 3100 | + | |
3078 | 3101 |
| |
3079 | 3102 |
| |
3080 | 3103 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4701 | 4701 |
| |
4702 | 4702 |
| |
4703 | 4703 |
| |
| 4704 | + | |
4704 | 4705 |
| |
4705 | 4706 |
| |
4706 | 4707 |
| |
| |||
5831 | 5832 |
| |
5832 | 5833 |
| |
5833 | 5834 |
| |
| 5835 | + | |
5834 | 5836 |
| |
5835 | 5837 |
| |
5836 | 5838 |
| |
| |||
5860 | 5862 |
| |
5861 | 5863 |
| |
5862 | 5864 |
| |
| 5865 | + | |
5863 | 5866 |
| |
5864 | 5867 |
| |
5865 | 5868 |
| |
5866 | 5869 |
| |
| 5870 | + | |
5867 | 5871 |
| |
5868 | 5872 |
| |
5869 | 5873 |
| |
| |||
6098 | 6102 |
| |
6099 | 6103 |
| |
6100 | 6104 |
| |
| 6105 | + | |
| 6106 | + | |
| 6107 | + | |
| 6108 | + | |
| 6109 | + | |
| 6110 | + | |
| 6111 | + | |
| 6112 | + | |
| 6113 | + | |
| 6114 | + | |
| 6115 | + | |
| 6116 | + | |
6101 | 6117 |
| |
6102 | 6118 |
| |
6103 | 6119 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
196 | 196 |
| |
197 | 197 |
| |
198 | 198 |
| |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
199 | 215 |
| |
200 | 216 |
| |
201 | 217 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3102 | 3102 |
| |
3103 | 3103 |
| |
3104 | 3104 |
| |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
3105 | 3114 |
| |
3106 | 3115 |
| |
3107 | 3116 |
| |
| |||
3549 | 3558 |
| |
3550 | 3559 |
| |
3551 | 3560 |
| |
| 3561 | + | |
| 3562 | + | |
| 3563 | + | |
| 3564 | + | |
| 3565 | + | |
| 3566 | + | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
3552 | 3572 |
| |
3553 | 3573 |
| |
3554 | 3574 |
| |
|
0 commit comments
Comments
(0)