use CREATE DATABASE STRATEGY = FILE_COPY in pg_upgrade
Nathan Bossart <nathandbossart@gmail.com>
From: Nathan Bossart <nathandbossart@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2024-06-04T19:39:23Z
Lists: pgsql-hackers
Attachments
- use_file_copy_for_pg_upgrade.patch (text/plain) patch
I noticed that the "Restoring database schemas in the new cluster" part of pg_upgrade can take a while if you have many databases, so I experimented with a couple different settings to see if there are any easy ways to speed it up. The FILE_COPY strategy for CREATE DATABASE helped quite significantly on my laptop. For ~3k empty databases, this step went from ~100 seconds to ~30 seconds with the attached patch. I see commit ad43a41 made a similar change for initdb, so there might even be an argument for back-patching this to v15 (where STRATEGY was introduced). One thing I still need to verify is that this doesn't harm anything when there are lots of objects in the databases, i.e., more WAL generated during many concurrent CREATE-DATABASE-induced checkpoints. Thoughts? -- nathan
Commits
-
Use CREATE DATABASE ... STRATEGY = FILE_COPY in pg_upgrade.
- 64f34eb2e2ce 18.0 landed
-
Use TRUNCATE to preserve relfilenode for pg_largeobject + index.
- bbe08b8869bd 16.0 cited
-
initdb: When running CREATE DATABASE, use STRATEGY = WAL_COPY.
- ad43a413c4f7 15.0 cited