From 9a994e37e08df3578f52011543dc28085dc18e21 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Fri, 22 Jun 2018 12:17:56 +0300 Subject: [PATCH] Fixes for vacuum_cleanup_index_scale_factor GUC option vacuum_cleanup_index_scale_factor was located in autovacuum group of GUCs. However, it affects not only autovacuum, but also manually run VACUUM. It appears that "client connection defaults" group of GUCs is more appropriate for vacuum_cleanup_index_scale_factor, because vacuum_*_age options are already located there. Also, vacuum_cleanup_index_scale_factor was missed in postgresql.conf.sample. So, add it there with appropriate comment. Author: Masahiko Sawada with minor editorization by me Discussion: https://postgr.es/m/CAD21AoArsoXMLKudXSKN679FRzs6oubEchM53bHwn8Tp%3D2boNg%40mail.gmail.com --- doc/src/sgml/config.sgml | 83 +++++++++---------- src/backend/utils/misc/guc.c | 2 +- src/backend/utils/misc/postgresql.conf.sample | 3 + 3 files changed, 43 insertions(+), 45 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index b60240ecfe..7bfbc87109 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1882,50 +1882,6 @@ include_dir 'conf.d' - - Index Vacuum - - - vacuum_cleanup_index_scale_factor (floating point) - - vacuum_cleanup_index_scale_factor configuration parameter - - - - - Specifies the fraction of the total number of heap tuples counted in - the previous statistics collection that can be inserted without - incurring an index scan at the VACUUM cleanup stage. - This setting currently applies to B-tree indexes only. - - - - If no tuples were deleted from the heap, B-tree indexes are still - scanned at the VACUUM cleanup stage when at least one - of the following conditions is met: the index statistics are stale, or - the index contains deleted pages that can be recycled during cleanup. - Index statistics are considered to be stale if the number of newly - inserted tuples exceeds the vacuum_cleanup_index_scale_factor - fraction of the total number of heap tuples detected by the previous - statistics collection. The total number of heap tuples is stored in - the index meta-page. Note that the meta-page does not include this data - until VACUUM finds no dead tuples, so B-tree index - scan at the cleanup stage can only be skipped if the second and - subsequent VACUUM cycles detect no dead tuples. - - - - The value can range from 0 to 100. - When vacuum_cleanup_index_scale_factor is set to - 0, index scans are never skipped during - VACUUM cleanup. The default value is 0.1. - - - - - - - Background Writer @@ -7003,6 +6959,45 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; + + vacuum_cleanup_index_scale_factor (floating point) + + vacuum_cleanup_index_scale_factor configuration parameter + + + + + Specifies the fraction of the total number of heap tuples counted in + the previous statistics collection that can be inserted without + incurring an index scan at the VACUUM cleanup stage. + This setting currently applies to B-tree indexes only. + + + + If no tuples were deleted from the heap, B-tree indexes are still + scanned at the VACUUM cleanup stage when at least one + of the following conditions is met: the index statistics are stale, or + the index contains deleted pages that can be recycled during cleanup. + Index statistics are considered to be stale if the number of newly + inserted tuples exceeds the vacuum_cleanup_index_scale_factor + fraction of the total number of heap tuples detected by the previous + statistics collection. The total number of heap tuples is stored in + the index meta-page. Note that the meta-page does not include this data + until VACUUM finds no dead tuples, so B-tree index + scan at the cleanup stage can only be skipped if the second and + subsequent VACUUM cycles detect no dead tuples. + + + + The value can range from 0 to 100. + When vacuum_cleanup_index_scale_factor is set to + 0, index scans are never skipped during + VACUUM cleanup. The default value is 0.1. + + + + + bytea_output (enum) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index fa3c8a7905..859ef931e7 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3248,7 +3248,7 @@ static struct config_real ConfigureNamesReal[] = }, { - {"vacuum_cleanup_index_scale_factor", PGC_USERSET, AUTOVACUUM, + {"vacuum_cleanup_index_scale_factor", PGC_USERSET, CLIENT_CONN_STATEMENT, gettext_noop("Number of tuple inserts prior to index cleanup as a fraction of reltuples."), NULL }, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index f43086f6d0..9e39baf466 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -575,6 +575,9 @@ #vacuum_freeze_table_age = 150000000 #vacuum_multixact_freeze_min_age = 5000000 #vacuum_multixact_freeze_table_age = 150000000 +#vacuum_cleanup_index_scale_factor = 0.1 # fraction of total number of tuples + # before index cleanup, 0 always performs + # index cleanup #bytea_output = 'hex' # hex, escape #xmlbinary = 'base64' #xmloption = 'content' -- 2.40.0