select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / RESOURCE USAGE

file_extend_method

Read PG 18 manual ↗

Specifies the method used to extend data files during bulk operations such as COPY.

Type
enum
Context
sighup
Measured default
posix_fallocate
Unit
Metadata snapshot
18
Allowed values
posix_fallocate, write_zeros

Definition PG 18 manual

Specifies the method used to extend data files during bulk operations such as COPY. The first available option is used as the default, depending on the operating system:

  • posix_fallocate (Unix) uses the standard POSIX interface for allocating disk space, but is missing on some systems. If it is present but the underlying file system doesn't support it, this option silently falls back to write_zeros. Current versions of BTRFS are known to disable compression when this option is used. This is the default on systems that have the function.

  • write_zeros extends files by writing out blocks of zero bytes. This is the default on systems that don't have the function posix_fallocate.

The write_zeros method is always used when data files are extended by 8 blocks or fewer.

Measured default history
Version intervalDefault
16 – 19posix_fallocate
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

file_extend_method chooses how PostgreSQL grows relation files during bulk extension: posix_fallocate when available or explicit zero writes. Extensions of eight blocks or fewer still use zero writes.

The first supported method is platform dependent. posix_fallocate reserves space without writing every block, but unsupported file systems silently fall back; on current BTRFS it can disable compression for the file.

This affects allocation behavior and bulk-write latency, not WAL durability. Storage reservations, sparse-file behavior, compression, and copy-on-write semantics vary by file system. Its SIGHUP context allows configuration reload without a server restart.

Operational considerations

Changing file_extend_method without applying its documented unit and configuration context.

Optimizing an isolated benchmark while ignoring concurrent aggregate resource use.

Assuming a configured value guarantees operating-system or storage behavior.

Failing to retest startup, failover, and workload latency after the change.

Workload guidance

OLAP: Large allocations or bulk I/O can make file_extend_method visible, but platform capability is the first gate. Benchmark on production-equivalent storage and include failure/fallback behavior.

OLTP: Keep file_extend_method at the detected/default value unless operating-system support and a controlled benchmark justify a change. Validate startup and recovery on the exact kernel and file system.

SMALL: Avoid nondefault file_extend_method on a small or heterogeneous fleet unless it solves a verified platform issue. Portability and reliable startup usually outweigh a speculative gain.

Version history 1
  1. PG 15 → 16added

Related entries

Further reading

Definition snapshot: english-manuals:b34a0c47baae1d29cee2ff7cc8b… · English manual source