From 7feaccc21791d9d745bac013e5e0396bdde2d81c Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 18 Oct 2014 21:35:46 -0400
Subject: [PATCH] Allow setting effective_io_concurrency even on unsupported
 systems

This matches the behavior of other parameters that are unsupported on
some systems (e.g., ssl).

Also document the default value.
---
 doc/src/sgml/config.sgml     | 4 ++++
 src/backend/utils/misc/guc.c | 4 ----
 src/bin/initdb/initdb.c      | 6 ++++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index 6ee17d84772..47b11922455 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -1892,6 +1892,10 @@ include_dir 'conf.d'
          in an error.  On some operating systems (e.g., Solaris), the function
          is present but does not actually do anything.
         </para>
+
+        <para>
+         The default is 1 on supported systems, otherwise 0.
+        </para>
        </listitem>
       </varlistentry>
 
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index dca533ac916..d7142d218dc 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -2258,11 +2258,7 @@ static struct config_int ConfigureNamesInt[] =
 
 	{
 		{"effective_io_concurrency",
-#ifdef USE_PREFETCH
 			PGC_USERSET,
-#else
-			PGC_INTERNAL,
-#endif
 			RESOURCES_ASYNCHRONOUS,
 			gettext_noop("Number of simultaneous requests that can be handled efficiently by the disk subsystem."),
 			gettext_noop("For RAID arrays, this should be approximately the number of drive spindles in the array.")
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index c8ff2cbc7bc..e6c9e480d33 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1288,6 +1288,12 @@ setup_config(void)
 	conflines = replace_token(conflines, "#dynamic_shared_memory_type = posix",
 							  repltok);
 
+#if !USE_PREFETCH
+	conflines = replace_token(conflines,
+							  "#effective_io_concurrency = 1",
+							  "#effective_io_concurrency = 0");
+#endif
+
 	snprintf(path, sizeof(path), "%s/postgresql.conf", pg_data);
 
 	writefile(path, conflines);
-- 
GitLab