- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit857f9c3
committed
Skip full index scan during cleanup of B-tree indexes when possible
Vacuum of index consists from two stages: multiple (zero of more) ambulkdeletecalls and one amvacuumcleanup call. When workload on particular tableis append-only, then autovacuum isn't intended to touch this table. However,user may run vacuum manually in order to fill visibility map and get benefitsof index-only scans. Then ambulkdelete wouldn't be called for indexesof such table (because no heap tuples were deleted), only amvacuumcleanup wouldbe called In this case, amvacuumcleanup would perform full index scan fortwo objectives: put recyclable pages into free space map and update indexstatistics.This patch allows btvacuumclanup to skip full index scan when two conditionsare satisfied: no pages are going to be put into free space map and indexstatistics isn't stalled. In order to check first condition, we storeoldest btpo_xact in the meta-page. When it's precedes RecentGlobalXmin, thenthere are some recyclable pages. In order to check second condition we storenumber of heap tuples observed during previous full index scan by cleanup.If fraction of newly inserted tuples is less thanvacuum_cleanup_index_scale_factor, then statistics isn't considered to bestalled. vacuum_cleanup_index_scale_factor can be defined as both reloption and GUC (default).This patch bumps B-tree meta-page version. Upgrade of meta-page is performed"on the fly": during VACUUM meta-page is rewritten with new version. No specialhandling in pg_upgrade is required.Author: Masahiko Sawada, Alexander KorotkovReview by: Peter Geoghegan, Kyotaro Horiguchi, Alexander Korotkov, Yura SokolovDiscussion:https://www.postgresql.org/message-id/flat/CAD21AoAX+d2oD_nrd9O2YkpzHaFr=uQeGr9s1rKC3O4ENc568g@mail.gmail.com1 parenteac93e2 commit857f9c3
File tree
23 files changed
+458
-45
lines changed- contrib
- amcheck
- pageinspect
- expected
- pgstattuple/expected
- doc/src/sgml
- ref
- src
- backend
- access
- common
- nbtree
- utils
- init
- misc
- include
- access
- utils
- test/regress
- expected
- sql
23 files changed
+458
-45
lines changedLines changed: 5 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1500 | 1500 |
| |
1501 | 1501 |
| |
1502 | 1502 |
| |
1503 |
| - | |
| 1503 | + | |
| 1504 | + | |
1504 | 1505 |
| |
1505 | 1506 |
| |
1506 |
| - | |
| 1507 | + | |
| 1508 | + | |
1507 | 1509 |
| |
1508 |
| - | |
| 1510 | + | |
1509 | 1511 |
| |
1510 | 1512 |
| |
1511 | 1513 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 |
| - | |
| 8 | + | |
| 9 | + | |
9 | 10 |
| |
10 | 11 |
| |
11 | 12 |
| |
|
Lines changed: 3 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
511 | 511 |
| |
512 | 512 |
| |
513 | 513 |
| |
514 |
| - | |
| 514 | + | |
515 | 515 |
| |
516 | 516 |
| |
517 | 517 |
| |
| |||
555 | 555 |
| |
556 | 556 |
| |
557 | 557 |
| |
| 558 | + | |
| 559 | + | |
558 | 560 |
| |
559 | 561 |
| |
560 | 562 |
| |
|
Lines changed: 9 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
7 |
| - | |
8 |
| - | |
9 |
| - | |
10 |
| - | |
11 |
| - | |
12 |
| - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
13 | 15 |
| |
14 | 16 |
| |
15 | 17 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + |
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1 | 1 |
| |
2 | 2 |
| |
3 |
| - | |
| 3 | + | |
4 | 4 |
| |
5 | 5 |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
51 |
| - | |
| 51 | + | |
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 |
| - | |
| 61 | + | |
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| |||
68 | 68 |
| |
69 | 69 |
| |
70 | 70 |
| |
71 |
| - | |
| 71 | + | |
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
| |||
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
81 |
| - | |
| 81 | + | |
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
| |||
229 | 229 |
| |
230 | 230 |
| |
231 | 231 |
| |
232 |
| - | |
| 232 | + | |
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
|
Lines changed: 25 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1882 | 1882 |
| |
1883 | 1883 |
| |
1884 | 1884 |
| |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
| 1906 | + | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
1885 | 1910 |
| |
1886 | 1911 |
| |
1887 | 1912 |
| |
|
Lines changed: 9 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
247 | 247 |
| |
248 | 248 |
| |
249 | 249 |
| |
250 |
| - | |
251 |
| - | |
252 |
| - | |
253 |
| - | |
254 |
| - | |
255 |
| - | |
256 |
| - | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
257 | 259 |
| |
258 | 260 |
| |
259 | 261 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
369 | 369 |
| |
370 | 370 |
| |
371 | 371 |
| |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
372 | 387 |
| |
373 | 388 |
| |
374 | 389 |
| |
|
Lines changed: 12 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
409 | 409 |
| |
410 | 410 |
| |
411 | 411 |
| |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
412 | 421 |
| |
413 | 422 |
| |
414 | 423 |
| |
| |||
1371 | 1380 |
| |
1372 | 1381 |
| |
1373 | 1382 |
| |
1374 |
| - | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
1375 | 1386 |
| |
1376 | 1387 |
| |
1377 | 1388 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
939 | 939 |
| |
940 | 940 |
| |
941 | 941 |
| |
| 942 | + | |
| 943 | + | |
| 944 | + | |
942 | 945 |
| |
943 | 946 |
| |
944 | 947 |
| |
| |||
997 | 1000 |
| |
998 | 1001 |
| |
999 | 1002 |
| |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
1000 | 1006 |
| |
1001 | 1007 |
| |
1002 | 1008 |
| |
| |||
2049 | 2055 |
| |
2050 | 2056 |
| |
2051 | 2057 |
| |
| 2058 | + | |
| 2059 | + | |
| 2060 | + | |
| 2061 | + | |
2052 | 2062 |
| |
2053 | 2063 |
| |
2054 | 2064 |
| |
| |||
2138 | 2148 |
| |
2139 | 2149 |
| |
2140 | 2150 |
| |
| 2151 | + | |
| 2152 | + | |
2141 | 2153 |
| |
2142 | 2154 |
| |
2143 | 2155 |
| |
|
0 commit comments
Comments
(0)