Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6ca33a8

Browse files
committed
Increase upper limit for vacuum_cleanup_index_scale_factor
Upper limits for vacuum_cleanup_index_scale_factor GUC and reloption were initially set to 100.0 in 857f9c3. However, after further discussion, it appears that some users like to disable B-tree cleanup index scan completely (assuming there are no deleted pages). vacuum_cleanup_index_scale_factor is used barely to protect against stalled index statistics. And after detailed consideration it appears that risk of stalled index statistics is low. And it would be nice to allow advanced users setting higher values of vacuum_cleanup_index_scale_factor. So, set upper limit for these GUC and reloption to DBL_MAX. Author: Alexander Korotkov Reviewed-by: Masahiko Sawada Discussion: https://postgr.es/m/CAC8Q8tJCb%3DgxhzcV7T6ctx7PY-Ux1oA-AsTJc6cAVNsQiYcCzA%40mail.gmail.com
1 parent c9301de commit 6ca33a8

File tree

5 files changed

+9
-7
lines changed

5 files changed

+9
-7
lines changed

doc/src/sgml/config.sgml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6989,7 +6989,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
69896989
</para>
69906990

69916991
<para>
6992-
The value can range from <literal>0</literal> to <literal>100</literal>.
6992+
The value should be non-negative.
69936993
When <varname>vacuum_cleanup_index_scale_factor</varname> is set to
69946994
<literal>0</literal>, index scans are never skipped during
69956995
<command>VACUUM</command> cleanup. The default value is <literal>0.1</literal>.

src/backend/access/common/reloptions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static relopt_real realRelOpts[] =
416416
RELOPT_KIND_BTREE,
417417
ShareUpdateExclusiveLock
418418
},
419-
-1, 0.0, 100.0
419+
-1, 0.0, DBL_MAX
420420
},
421421
/* list terminator */
422422
{{NULL}}

src/backend/access/nbtree/nbtree.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,7 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
816816
{
817817
StdRdOptions *relopts;
818818
float8 cleanup_scale_factor;
819+
float8 prev_num_heap_tuples;
819820

820821
/*
821822
* If table receives enough insertions and no cleanup was performed,
@@ -829,11 +830,12 @@ _bt_vacuum_needs_cleanup(IndexVacuumInfo *info)
829830
relopts->vacuum_cleanup_index_scale_factor >= 0)
830831
? relopts->vacuum_cleanup_index_scale_factor
831832
: vacuum_cleanup_index_scale_factor;
833+
prev_num_heap_tuples = metad->btm_last_cleanup_num_heap_tuples;
832834

833835
if (cleanup_scale_factor <= 0 ||
834-
metad->btm_last_cleanup_num_heap_tuples < 0 ||
835-
info->num_heap_tuples > (1.0 + cleanup_scale_factor) *
836-
metad->btm_last_cleanup_num_heap_tuples)
836+
prev_num_heap_tuples < 0 ||
837+
(info->num_heap_tuples - prev_num_heap_tuples) /
838+
prev_num_heap_tuples >= cleanup_scale_factor)
837839
result = true;
838840
}
839841

src/backend/utils/misc/guc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3253,7 +3253,7 @@ static struct config_real ConfigureNamesReal[] =
32533253
NULL
32543254
},
32553255
&vacuum_cleanup_index_scale_factor,
3256-
0.1, 0.0, 100.0,
3256+
0.1, 0.0, DBL_MAX,
32573257
NULL, NULL, NULL
32583258
},
32593259

src/test/regress/expected/btree_index.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ select reloptions from pg_class WHERE oid = 'btree_idx1'::regclass;
165165
-- Fail while setting improper values
166166
create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = -10.0);
167167
ERROR: value -10.0 out of bounds for option "vacuum_cleanup_index_scale_factor"
168-
DETAIL: Valid values are between "0.000000" and "100.000000".
168+
DETAIL: Valid values are between "0.000000" and "179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368.000000".
169169
create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 100.0);
170170
create index btree_idx_err on btree_test(a) with (vacuum_cleanup_index_scale_factor = 'string');
171171
ERROR: invalid value for floating point option "vacuum_cleanup_index_scale_factor": string

0 commit comments

Comments
 (0)