0001-Use-file_copy-strategy-during-initdb.patch
text/x-patch
Filename: 0001-Use-file_copy-strategy-during-initdb.patch
Type: text/x-patch
Part: 1
Patch
Format: format-patch
Series: patch 0001
Subject: Use file_copy strategy during initdb
| File | + | − |
|---|---|---|
| src/bin/initdb/initdb.c | 11 | 3 |
From 4a997e2a95074a520777cd2b369f9c728b360969 Mon Sep 17 00:00:00 2001
From: Dilip Kumar <dilipkumar@localhost.localdomain>
Date: Thu, 31 Mar 2022 10:43:16 +0530
Subject: [PATCH 1/2] Use file_copy strategy during initdb
Because skipping the checkpoint during initdb will not result
in significant savings, so there is no point in using wal_log
as that will simply increase the cluster size by generating
extra wal.
---
src/bin/initdb/initdb.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 5e36943..1256082 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1856,6 +1856,11 @@ make_template0(FILE *cmdfd)
* it would fail. To avoid that, assign a fixed OID to template0 rather
* than letting the server choose one.
*
+ * Using file_copy strategy is preferable over wal_log here because
+ * skipping the checkpoint during initdb will not result in significant
+ * savings, so there is no point in using wal_log as that will simply
+ * increase the cluster size by generating extra wal.
+ *
* (Note that, while the user could have dropped and recreated these
* objects in the old cluster, the problem scenario only exists if the OID
* that is in use in the old cluster is also used in the new cluster - and
@@ -1863,7 +1868,7 @@ make_template0(FILE *cmdfd)
*/
static const char *const template0_setup[] = {
"CREATE DATABASE template0 IS_TEMPLATE = true ALLOW_CONNECTIONS = false OID = "
- CppAsString2(Template0ObjectId) ";\n\n",
+ CppAsString2(Template0ObjectId) " STRATEGY = file_copy;\n\n",
/*
* template0 shouldn't have any collation-dependent objects, so unset
@@ -1899,7 +1904,10 @@ make_template0(FILE *cmdfd)
}
/*
- * copy template1 to postgres
+ * copy template1 to postgres.
+ *
+ * Use file_copy for creating the database; the reason for this is explained in
+ * comments atop template0_setup.
*/
static void
make_postgres(FILE *cmdfd)
@@ -1908,7 +1916,7 @@ make_postgres(FILE *cmdfd)
/* Assign a fixed OID to postgres, for the same reasons as template0 */
static const char *const postgres_setup[] = {
- "CREATE DATABASE postgres OID = " CppAsString2(PostgresObjectId) ";\n\n",
+ "CREATE DATABASE postgres OID = " CppAsString2(PostgresObjectId) " STRATEGY = FILE_COPY;\n\n",
"COMMENT ON DATABASE postgres IS 'default administrative connection database';\n\n",
NULL
};
--
1.8.3.1