select open change scope Open full search

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

CONFIGURATION / FILE LOCATIONS

data_directory

Read PG 18 manual ↗

Specifies the directory to use for data storage.

Type
string
Context
postmaster
Measured default
Not specified
Unit
Metadata snapshot
18

Definition PG 18 manual

Specifies the directory to use for data storage. This parameter can only be set at server start.

Measured default history
Version intervalDefault
9.0 – 19Not specified
Analysis & operational context

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

How it works

Sets the server's data directory. The value is fixed when the server starts, so changing it requires a restart.

This selects the cluster storage directory and overrides -D or PGDATA for data placement, but it does not relocate the already selected configuration files. Moving a cluster requires a coordinated shutdown and filesystem operation; changing only the string cannot move data.

Monitor and change data_directory together with allow_alter_system, config_file, hba_file. Validate on the relevant server role and real workload, then use its postmaster context to choose session change, reload, or restart; a historical boot default is not the current effective value.

Operational considerations

Missing directory traversal, read, or write permission for the service account.

Confusing restart requirements for a path with reload behavior of the selected file contents.

Omitting the path on a failover node or from backup inventory.

Using a relative path that depends on an unstable working directory.

Workload guidance

OLAP: Follow the OLTP rule, and for separate mounts also verify boot ordering, backup coverage, and path consistency on failover nodes.

OLTP: data_directory is deployment topology, not workload tuning. Use an absolute path, least privilege, and atomic configuration rollout; verify access as the postgres service account before restart/reload.

SMALL: The default co-located layout is simplest. Split paths only for a concrete backup, packaging, or permission-isolation benefit.

Related entries

Further reading

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