pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Munro <tmunro@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Introduce file_copy_method setting.
Date: Tue, 08 Apr 2025 09:35:52 +0000
Message-ID: <E1u25N2-003GyZ-1O@gemulon.postgresql.org> (raw)

Introduce file_copy_method setting.

It can be set to either COPY (the default) or CLONE if the system
supports it.  CLONE causes callers of copydir(), currently CREATE
DATABASE ... STRATEGY=FILE_COPY and ALTER DATABASE ... SET TABLESPACE =
..., to use copy_file_range (Linux, FreeBSD) or copyfile (macOS) to copy
files instead of a read-write loop over the contents.

CLONE gives the kernel the opportunity to share block ranges on
copy-on-write file systems and push copying down to storage on others,
depending on configuration.  On some systems CLONE can be used to clone
large databases quickly with CREATE DATABASE ... TEMPLATE=source
STRATEGY=FILE_COPY.

Other operating systems could be supported; patches welcome.

Co-authored-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Reviewed-by: Ranier Vilela <ranier.vf@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGLM%2Bt%2BSwBU-cHeMUXJCOgBxSHLGZutV5zCwY4qrCcE02w%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f78ca6f3ebbbff8c675c34b8ee61047223073866

Modified Files
--------------
doc/src/sgml/config.sgml                        | 38 ++++++++++++
doc/src/sgml/ref/alter_database.sgml            |  3 +-
doc/src/sgml/ref/create_database.sgml           |  4 +-
src/backend/storage/file/copydir.c              | 80 ++++++++++++++++++++++++-
src/backend/utils/activity/wait_event_names.txt |  1 +
src/backend/utils/misc/guc_tables.c             | 22 +++++++
src/backend/utils/misc/postgresql.conf.sample   |  4 ++
src/include/storage/copydir.h                   |  9 +++
src/tools/pgindent/typedefs.list                |  1 +
9 files changed, 159 insertions(+), 3 deletions(-)



Message-ID: <E1u25N2-003GyZ-1O@gemulon.postgresql.org>
Permalink:  ../E1u25N2-003GyZ-1O@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1u25N2-003GyZ-1O@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tmunro@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Introduce file_copy_method setting.
  In-Reply-To: <E1u25N2-003GyZ-1O@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox