Increase default effective_io_concurrency to 16
authorMelanie Plageman <[email protected]>
Wed, 12 Mar 2025 19:56:59 +0000 (15:56 -0400)
committerMelanie Plageman <[email protected]>
Wed, 12 Mar 2025 19:57:44 +0000 (15:57 -0400)
The default effective_io_concurrency has been 1 since it was introduced
in b7b8f0b6096d2ab6e. Referencing the associated discussion [1], it
seems 1 was chosen as a conservative value that seemed unlikely to cause
regressions.

Experimentation on high latency cloud storage as well as fast, local
nvme storage (see Discussion link) shows that even slightly higher
values improve query timings substantially. 1 actually performs worse
than 0 [2]. With effective_io_concurrency 1, we are not prefetching
enough to avoid I/O stalls, but we are issuing extra syscalls.

The new default is 16, which should be more appropriate for common
hardware while still avoiding flooding low IOPs devices with I/O
requests.

[1] https://www.postgresql.org/message-id/flat/FDDBA24E-FF4D-4654-BA75-692B3BA71B97%40enterprisedb.com
[2] https://www.postgresql.org/message-id/CAAKRu_Zv08Cic%3DqdCfzrQabpEXGrd9Z9UOW5svEVkCM6%3DFXA9g%40mail.gmail.com

Reviewed-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/CAAKRu_Z%2BJa-mwXebOoOERMMUMvJeRhzTjad4dSThxG0JLXESxw%40mail.gmail.com

doc/src/sgml/config.sgml
src/backend/utils/misc/postgresql.conf.sample
src/include/storage/bufmgr.h

index 7ece94474d9efb241166f268f5765598efc6ea61..8c82b39a89d9c5ede75de2a06d62db3a5c835223 100644 (file)
@@ -2574,39 +2574,33 @@ include_dir 'conf.d'
        </term>
        <listitem>
         <para>
-         Sets the number of concurrent disk I/O operations that
+         Sets the number of concurrent storage I/O operations that
          <productname>PostgreSQL</productname> expects can be executed
          simultaneously.  Raising this value will increase the number of I/O
-         operations that any individual <productname>PostgreSQL</productname> session
-         attempts to initiate in parallel.  The allowed range is 1 to 1000,
-         or zero to disable issuance of asynchronous I/O requests. Currently,
-         this setting only affects bitmap heap scans.
+         operations that any individual <productname>PostgreSQL</productname>
+         session attempts to initiate in parallel.  The allowed range is
+         <literal>1</literal> to <literal>1000</literal>, or
+         <literal>0</literal> to disable issuance of asynchronous I/O requests.
+         The default is <literal>16</literal> on supported systems, otherwise
+         <literal>0</literal>.
         </para>
 
         <para>
-         For magnetic drives, a good starting point for this setting is the
-         number of separate
-         drives comprising a RAID 0 stripe or RAID 1 mirror being used for the
-         database.  (For RAID 5 the parity drive should not be counted.)
-         However, if the database is often busy with multiple queries issued in
-         concurrent sessions, lower values may be sufficient to keep the disk
-         array busy.  A value higher than needed to keep the disks busy will
-         only result in extra CPU overhead.
-         SSDs and other memory-based storage can often process many
-         concurrent requests, so the best value might be in the hundreds.
+         Higher values will have the most impact on higher latency storage
+         where queries otherwise experience noticeable I/O stalls and on
+         devices with high IOPs. Unnecessarily high values may increase I/O
+         latency for all queries on the system
         </para>
 
         <para>
-         Asynchronous I/O requires that the operating system supports issuing
-         read-ahead advice.  If there is no operating system support then
-         setting this parameter to anything but zero will result in an error.
+         On systems without prefetch advice support, attempting to configure
+         any value other than <literal>0</literal> will error out.
         </para>
 
         <para>
-         The default is 1 on supported systems, otherwise 0.  This value can
-         be overridden for tables in a particular tablespace by setting the
-         tablespace parameter of the same name (see
-         <xref linkend="sql-altertablespace"/>).
+         This value can be overridden for tables in a particular tablespace by
+         setting the tablespace parameter of the same name (see <xref
+         linkend="sql-altertablespace"/>).
         </para>
        </listitem>
       </varlistentry>
index d2bd329a587aa1add7286536faa1df6b410db41c..36cb64d7ebca9f9a043d94412052eec04fa9e4b9 100644 (file)
 # - I/O -
 
 #backend_flush_after = 0       # measured in pages, 0 disables
-#effective_io_concurrency = 1      # 1-1000; 0 disables prefetching
+#effective_io_concurrency = 16     # 1-1000; 0 disables prefetching
 #maintenance_io_concurrency = 10   # 1-1000; 0 disables prefetching
 #io_combine_limit = 128kB      # usually 1-32 blocks (depends on OS)
 
index 7c1e4316dded7b3f2d95efd9e0940fff647550f7..b204e4731c18d41f7a216d85c6809c4a790bd1f5 100644 (file)
@@ -152,7 +152,7 @@ extern PGDLLIMPORT bool track_io_timing;
 
 /* only applicable when prefetching is available */
 #ifdef USE_PREFETCH
-#define DEFAULT_EFFECTIVE_IO_CONCURRENCY 1
+#define DEFAULT_EFFECTIVE_IO_CONCURRENCY 16
 #define DEFAULT_MAINTENANCE_IO_CONCURRENCY 10
 #else
 #define DEFAULT_EFFECTIVE_IO_CONCURRENCY 0