file_copy_method
Fact — official short description: “Selects the file copy method.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG18 |
| Present in | PG18–19 Beta 3 |
| Removed in | No |
| Introduction commit | f78ca6f3ebbb — Introduce file_copy_method setting. |
| Commit date | 2025-04-08 |
| Discussion | thread 1 |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG18–19 Beta 3 | copy |
— | copy |
How it works
file_copy_method chooses COPY or CLONE for CREATE DATABASE … STRATEGY=FILE_COPY and ALTER DATABASE … SET TABLESPACE. It does not change SQL COPY or general file reads.
CLONE uses copy_file_range() on Linux/FreeBSD or copyfile on macOS, allowing supporting file systems to share blocks or offload the operation. Availability and the actual optimization depend on the operating system and file system; selecting CLONE does not prove that blocks were shared.
Copy-on-write can make the initial operation fast, but later writes allocate private blocks and snapshots still share failure domains. Backup, quota, and free-space accounting must understand the file system semantics. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.
Tuning advice
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Use COPY as the compatibility baseline. Select CLONE only after CREATE DATABASE … STRATEGY=FILE_COPY and ALTER DATABASE … SET TABLESPACE are tested on the exact kernel and file system, including backup, quota, and free-space monitoring. |
| OLAP | Workload type does not determine the method; clone support and copy-on-write behavior do. CLONE can shorten large database copies, but benchmark the initial operation and subsequent write amplification before standardizing it. |
| Small nodes | Prefer COPY unless the file system’s clone semantics are known and operational tooling understands shared extents. A fast initial clone can still create later space pressure on a small volume. |
Pigsty
Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.
| Template | Effective value | Versus upstream boot | Source expression |
|---|---|---|---|
| OLTP | clone |
different | clone |
| OLAP | clone |
different | clone |
| CRIT | clone |
different | clone |
| TINY | clone |
different | clone |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG18–19 Beta 3 = clone (dcs); OLAP: PG18–19 Beta 3 = clone (dcs); CRIT: PG18–19 Beta 3 = clone (dcs); TINY: PG18–19 Beta 3 = clone (dcs). Advice, pending human review — Editorial inference, pending maintainer review: The template comment explicitly targets near-instant database cloning on copy-on-write file systems; support and free-space semantics still require deployment validation.
Common pitfalls
- Assuming CLONE guarantees copy-on-write block sharing; the kernel and file system decide the actual optimization.
- Expecting the parameter to affect SQL COPY or ordinary relation reads.
- Ignoring later private-block allocation and free-space pressure after a fast clone.
- Using CLONE before backup, quota, and filesystem tooling understand shared extents.
Related parameters
file_extend_method · data_directory · temp_tablespaces · shared_buffers