Reduce the default value of vacuum_cost_page_miss.
authorPeter Geoghegan <pg@bowt.ie>
Wed, 27 Jan 2021 23:11:13 +0000 (15:11 -0800)
committerPeter Geoghegan <pg@bowt.ie>
Wed, 27 Jan 2021 23:11:13 +0000 (15:11 -0800)
When commit f425b605 introduced cost based vacuum delays back in 2004,
the defaults reflected then-current trends in hardware, as well as
certain historical limitations in PostgreSQL.  There have been enormous
improvements in both areas since that time.  The cost limit GUC defaults
finally became much more representative of current trends following
commit cbccac37, which decreased autovacuum_vacuum_cost_delay's default
by 10x for PostgreSQL 12 (it went from 20ms to only 2ms).

The relative costs have shifted too.  This should also be accounted for
by the defaults.  More specifically, the relative importance of avoiding
dirtying pages within VACUUM has greatly increased, primarily due to
main memory capacity scaling and trends in flash storage.  Within
Postgres itself, improvements like sequential access during index
vacuuming (at least in nbtree and GiST indexes) have also been
contributing factors.

To reflect all this, decrease the default of vacuum_cost_page_miss to 2.
Since the default of vacuum_cost_page_dirty remains 20, dirtying a page
is now considered 10x "costlier" than a page miss by default.

Author: Peter Geoghegan <pg@bowt.ie>
Discussion: https://postgr.es/m/CAH2-WzmLPFnkWT8xMjmcsm7YS3+_Qi3iRWAb2+_Bc8UhVyHfuA@mail.gmail.com

doc/src/sgml/config.sgml
src/backend/utils/init/globals.c
src/backend/utils/misc/guc.c
src/backend/utils/misc/postgresql.conf.sample

index 82864bbb247f55c0b6bb3ce2686a8d6404673a82..f1037df5a98e43e42f1d0dee2469939c501f419b 100644 (file)
@@ -2116,7 +2116,7 @@ include_dir 'conf.d'
          The estimated cost for vacuuming a buffer that has to be read from
          disk.  This represents the effort to lock the buffer pool,
          lookup the shared hash table, read the desired block in from
-         the disk and scan its content. The default value is 10.
+         the disk and scan its content. The default value is 2.
         </para>
        </listitem>
       </varlistentry>
index ea28769d6a3966a496f139c66816ea202b798c34..a5976ad5b11a8d92683a4085294c8823e43aa47d 100644 (file)
@@ -137,7 +137,7 @@ int         max_parallel_workers = 8;
 int            MaxBackends = 0;
 
 int            VacuumCostPageHit = 1;  /* GUC parameters for vacuum */
-int            VacuumCostPageMiss = 10;
+int            VacuumCostPageMiss = 2;
 int            VacuumCostPageDirty = 20;
 int            VacuumCostLimit = 200;
 double     VacuumCostDelay = 0;
index 17579eeaca9c6a0851a4fd2062266b14c72dc0fe..eafdb1118ed57b746892d0478b0f5b0b268b93bd 100644 (file)
@@ -2413,7 +2413,7 @@ static struct config_int ConfigureNamesInt[] =
            NULL
        },
        &VacuumCostPageMiss,
-       10, 0, 10000,
+       2, 0, 10000,
        NULL, NULL, NULL
    },
 
index 8930a94fff5a5b71f3d1c92b6eed3ee4bfa3f6cd..bd57e917e16edda5472f5ff0c6316f98a0a525d1 100644 (file)
 
 #vacuum_cost_delay = 0         # 0-100 milliseconds (0 disables)
 #vacuum_cost_page_hit = 1      # 0-10000 credits
-#vacuum_cost_page_miss = 10        # 0-10000 credits
+#vacuum_cost_page_miss = 2     # 0-10000 credits
 #vacuum_cost_page_dirty = 20       # 0-10000 credits
 #vacuum_cost_limit = 200       # 1-10000 credits