diff options
author | Thomas Munro | 2025-04-08 08:52:47 +0000 |
---|---|---|
committer | Thomas Munro | 2025-04-08 09:35:38 +0000 |
commit | f78ca6f3ebbbff8c675c34b8ee61047223073866 (patch) | |
tree | c3543200c7b119226fb6b1266db6dfd463b02267 /doc/src | |
parent | 042a66291b04f473cbc72f95f07438abd75ae3a9 (diff) |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/config.sgml | 38 | ||||
-rw-r--r-- | doc/src/sgml/ref/alter_database.sgml | 3 | ||||
-rw-r--r-- | doc/src/sgml/ref/create_database.sgml | 4 |
3 files changed, 43 insertions, 2 deletions
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index a8542fe41ce..c1674c22cb2 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -2347,6 +2347,44 @@ include_dir 'conf.d' </listitem> </varlistentry> + <varlistentry id="guc_file_copy_method" xreflabel="file_copy_method"> + <term><varname>file_copy_method</varname> (<type>enum</type>) + <indexterm> + <primary><varname>file_copy_method</varname> configuration parameter</primary> + </indexterm> + </term> + <listitem> + <para> + Specifies the method used to copy files. + Possible values are <literal>COPY</literal> (default) and + <literal>CLONE</literal> (if operating support is available). + </para> + + <para> + This parameter affects: + </para> + <itemizedlist> + <listitem> + <para> + <literal><command>CREATE DATABASE ... STRATEGY=FILE_COPY</command></literal> + </para> + </listitem> + <listitem> + <para> + <command>ALTER DATABASE ... SET TABLESPACE ...</command> + </para> + </listitem> + </itemizedlist> + + <para> + <literal>CLONE</literal> uses the <function>copy_file_range()</function> + (Linux, FreeBSD) or <function>copyfile</function> + (macOS) system calls, giving the kernel the opportunity to share disk + blocks or push work down to lower layers on some file systems. + </para> + </listitem> + </varlistentry> + <varlistentry id="guc-max-notify-queue-pages" xreflabel="max_notify_queue_pages"> <term><varname>max_notify_queue_pages</varname> (<type>integer</type>) <indexterm> diff --git a/doc/src/sgml/ref/alter_database.sgml b/doc/src/sgml/ref/alter_database.sgml index 2479c41e8d6..835c1af87eb 100644 --- a/doc/src/sgml/ref/alter_database.sgml +++ b/doc/src/sgml/ref/alter_database.sgml @@ -82,7 +82,8 @@ ALTER DATABASE <replaceable class="parameter">name</replaceable> RESET ALL default tablespace to the new tablespace. The new default tablespace must be empty for this database, and no one can be connected to the database. Tables and indexes in non-default tablespaces are - unaffected. + unaffected. The method used to copy files to the new tablespace + is affected by the <xref glinkend="guc_file_copy_method"/> setting. </para> <para> diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml index a4b052ba08b..640c0425fae 100644 --- a/doc/src/sgml/ref/create_database.sgml +++ b/doc/src/sgml/ref/create_database.sgml @@ -138,7 +138,9 @@ CREATE DATABASE <replaceable class="parameter">name</replaceable> log volume substantially, especially if the template database is large, it also forces the system to perform a checkpoint both before and after the creation of the new database. In some situations, this may - have a noticeable negative impact on overall system performance. + have a noticeable negative impact on overall system performance. The + <literal>FILE_COPY</literal> strategy is affected by the <xref + linkend="guc_file_copy_method"/> setting. </para> </listitem> </varlistentry> |