Increase default vacuum_buffer_usage_limit to 2MB.
authorThomas Munro <[email protected]>
Sat, 6 Apr 2024 10:00:40 +0000 (23:00 +1300)
committerThomas Munro <[email protected]>
Sat, 6 Apr 2024 10:12:03 +0000 (23:12 +1300)
The BAS_VACUUM ring size has been 256kB since commit d526575f introduced
the mechanism 17 years ago.  Commit 1cbbee03 recently made it
configurable but retained the traditional default.  The correct default
size has been debated for years, but 256kB is certainly very small.
VACUUM soon needs to write back data it dirtied only 32 blocks ago,
which usually requires flushing the WAL.  New experiments in prefetching
pages for VACUUM exacerbated the problem by crashing into dirty data
even sooner.  Let's make the default 2MB.  That's 1.6% of the default
toy buffer pool size, and 0.2% of 1GB, which would be a considered a
small shared_buffers setting for a real system these days.  Users are
still free to set the GUC to a different value.

Reviewed-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/20240403221257.md4gfki3z75cdyf6%40awork3.anarazel.de
Discussion: https://postgr.es/m/CA%2BhUKGLY4Q4ZY4f1rvnFtv6%2BPkjNf8MejdPkcju3Qii9DYqqcQ%40mail.gmail.com

doc/src/sgml/config.sgml
src/backend/storage/buffer/freelist.c
src/backend/utils/init/globals.c
src/backend/utils/misc/guc_tables.c
src/backend/utils/misc/postgresql.conf.sample

index 624518e0b01df79625196dd086f12b97a53fcf28..d8e1282e128d7fefc6acc327a1107f01f5fbda2e 100644 (file)
@@ -1961,7 +1961,7 @@ include_dir 'conf.d'
         valid sizes range from <literal>128 kB</literal> to
         <literal>16 GB</literal>.  If the specified size would exceed 1/8 the
         size of <varname>shared_buffers</varname>, the size is silently capped
-        to that value.  The default value is <literal>256 kB</literal>.  If
+        to that value.  The default value is <literal>2MB</literal>.  If
         this value is specified without units, it is taken as kilobytes.  This
         parameter can be set at any time.  It can be overridden for
         <xref linkend="sql-vacuum"/> and <xref linkend="sql-analyze"/>
index de2ef1dd5e663f3c9f3fd6fde12e63b6509aa024..19797de31a9c82c5d0bebd9919c93f62b6e39145 100644 (file)
@@ -561,7 +561,7 @@ GetAccessStrategy(BufferAccessStrategyType btype)
            ring_size_kb = 16 * 1024;
            break;
        case BAS_VACUUM:
-           ring_size_kb = 256;
+           ring_size_kb = 2048;
            break;
 
        default:
index 3e38bb1311d6f0df9fe5abe21aea99199ed37198..cc61937eef749e5247fcde574e7de1fe730e3d40 100644 (file)
@@ -143,7 +143,7 @@ int         max_parallel_workers = 8;
 int            MaxBackends = 0;
 
 /* GUC parameters for vacuum */
-int            VacuumBufferUsageLimit = 256;
+int            VacuumBufferUsageLimit = 2048;
 
 int            VacuumCostPageHit = 1;
 int            VacuumCostPageMiss = 2;
index c12784cbec86bbf572de7d028a2b759e4d17a67f..7d4e4387cf5f3c476e8f839fef9cd7d3ae517c91 100644 (file)
@@ -2275,7 +2275,7 @@ struct config_int ConfigureNamesInt[] =
            GUC_UNIT_KB
        },
        &VacuumBufferUsageLimit,
-       256, 0, MAX_BAS_VAC_RING_SIZE_KB,
+       2048, 0, MAX_BAS_VAC_RING_SIZE_KB,
        check_vacuum_buffer_usage_limit, NULL, NULL
    },
 
index baecde2841033deca30af3c5096bc0167681a5c6..2166ea4a87aa229e5ba3fbbb00c05aac9550f512 100644 (file)
                    #   mmap
                    # (change requires restart)
 #min_dynamic_shared_memory = 0MB   # (change requires restart)
-#vacuum_buffer_usage_limit = 256kB # size of vacuum and analyze buffer access strategy ring;
+#vacuum_buffer_usage_limit = 2MB   # size of vacuum and analyze buffer access strategy ring;
                    # 0 to disable vacuum buffer access strategy;
                    # range 128kB to 16GB