From ad43a413c4f7f5d024a5b2f51e00d280a22f1874 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 31 Mar 2022 15:15:11 -0400 Subject: [PATCH] initdb: When running CREATE DATABASE, use STRATEGY = WAL_COPY. Dilip Kumar, reviewed by Andres Freund and by me. Discussion: http://postgr.es/m/20220330011757.wr544o5y5my7ssoa@alap3.anarazel.de --- 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 5e36943ef3..9dd4a8de9a 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1860,10 +1860,15 @@ make_template0(FILE *cmdfd) * 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 * the new cluster should be the result of a fresh initdb.) + * + * We use "STRATEGY = file_copy" here because checkpoints during initdb + * are cheap. "STRATEGY = wal_log" would generate more WAL, which would + * be a little bit slower and make the new cluster a little bit bigger. */ 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 @@ -1906,9 +1911,12 @@ make_postgres(FILE *cmdfd) { const char *const *line; - /* Assign a fixed OID to postgres, for the same reasons as template0 */ + /* + * Just as we did for template0, and for the same reasons, assign a fixed + * OID to postgres and select the file_copy strategy. + */ 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 }; -- 2.39.5