Re: use CREATE DATABASE STRATEGY = FILE_COPY in pg_upgrade
Matthias van de Meent <boekewurm+postgres@gmail.com>
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: Ranier Vilela <ranier.vf@gmail.com>,
Nathan Bossart <nathandbossart@gmail.com>, pgsql-hackers@postgresql.org
Date: 2024-06-07T06:27:37Z
Lists: pgsql-hackers
On Fri, 7 Jun 2024 at 07:18, Dilip Kumar <dilipbalaut@gmail.com> wrote: > > On Wed, Jun 5, 2024 at 10:59 PM Matthias van de Meent > <boekewurm+postgres@gmail.com> wrote: >> >> On Wed, 5 Jun 2024 at 18:47, Ranier Vilela <ranier.vf@gmail.com> wrote: >>> >>> Why not use it too, if not binary_upgrade? >> >> Because in the normal case (not during binary_upgrade) you don't want >> to have to generate 2 checkpoints for every created database, >> especially not when your shared buffers are large. Checkpoints' costs >> scale approximately linearly with the size of shared buffers, so being >> able to skip those checkpoints (with strategy=WAL_LOG) will save a lot >> of performance in the systems where this performance impact matters >> most. > > I agree with you that we introduced the WAL_LOG strategy to avoid > these force checkpoints. However, in binary upgrade cases where no > operations are happening in the system, the FILE_COPY strategy should > be faster. While you would be correct if there were no operations happening in the system, during binary upgrade we're still actively modifying catalogs; and this is done with potentially many concurrent jobs. I think it's not unlikely that this would impact performance. Now that I think about it, arguably, we shouldn't need to run checkpoints during binary upgrade for the FILE_COPY strategy after we've restored the template1 database and created a checkpoint after that: All other databases use template1 as their template database, and the checkpoint is there mostly to guarantee the FS knows about all changes in the template database before we task it with copying the template database over to our new database, so the protections we get from more checkpoints are practically useless. If such a change were implemented (i.e. no checkpoints for FILE_COPY in binary upgrade, with a single manual checkpoint after restoring template1 in create_new_objects) I think most of my concerns with this patch would be alleviated. Kind regards, Matthias van de Meent
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