mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user