diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-03-31 15:15:11 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-03-31 15:15:11 -0400 |
commit | ad43a413c4f7f5d024a5b2f51e00d280a22f1874 (patch) | |
tree | 3f6ad88f66e4d7b38a717d1245ba765a93552ed0 /src | |
parent | f3dd9fe1dd9254680591aa8d9891b90b8d735b2a (diff) | |
download | postgresql-ad43a413c4f7f5d024a5b2f51e00d280a22f1874.tar.gz postgresql-ad43a413c4f7f5d024a5b2f51e00d280a22f1874.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/initdb/initdb.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 5e36943ef3b..9dd4a8de9a8 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 }; |