Skip to main content
PostgreSQL tablespaces let you store database objects (tables, indexes) on a filesystem path separate from the main data directory. Common use cases include placing large or infrequently accessed tables on cheaper storage, directing I/O-intensive indexes to faster disks, or satisfying data-placement requirements across storage tiers. PGO supports tablespaces through the TablespaceVolumes feature gate. Each tablespace is backed by its own PersistentVolumeClaim, and PGO handles creating the directory structure and registering the tablespace inside PostgreSQL automatically.
TablespaceVolumes is an alpha feature that is disabled by default. Alpha features may change or be removed in future releases. Do not rely on them for production workloads without thoroughly testing upgrades.

Enable the feature gate

To use tablespace volumes, enable the TablespaceVolumes feature gate on the operator deployment. Add the flag to the operator’s startup arguments:
For Kustomize-based installations, patch the operator Deployment to add the --feature-gates argument. For Helm installations, consult the chart’s values.yaml for the feature gate configuration option.

Define tablespace volumes

Once the feature gate is enabled, add a tablespaceVolumes list to the instance set definition. Each entry requires a unique name and a dataVolumeClaimSpec describing the PersistentVolumeClaim.

TablespaceVolume fields

How PGO sets up tablespace directories

When TablespaceVolumes is enabled and configured, PGO:
  1. Creates a PersistentVolumeClaim for each tablespaceVolumes entry.
  2. Mounts each PVC into the instance pod.
  3. Creates the required PostgreSQL tablespace directory structure inside the mounted volume.
  4. Creates a symlink so PostgreSQL can locate the tablespace at the expected path.
  5. Registers the tablespace in PostgreSQL using CREATE TABLESPACE.
You do not need to run CREATE TABLESPACE manually; PGO handles the full lifecycle.

Use a tablespace in PostgreSQL

Once the tablespace is created by PGO, you can use it by name in SQL:

Considerations

  • Name constraints: Tablespace names must match ^[a-z][a-z0-9]*$. They must be unique within an instance set because they become both the directory path and the PostgreSQL tablespace identifier.
  • Volume expansion: Tablespace PVCs can be resized using the same approach as the main data volume. See Resize cluster resources.
  • Replicas: Each instance in the set gets its own PVC per tablespace. PGO ensures tablespace directories exist on all instances so that replicas can follow the primary correctly.
  • Backups: pgBackRest does not automatically back up tablespace volumes that are separate PVCs. Ensure your backup strategy accounts for tablespace data.

Next steps

Resize cluster resources

Expand tablespace PVCs and adjust compute resources.

Feature gates reference

View all available feature gates and their maturity stages.