Tablespaces

TABLESPACE declarations — cluster-level objects that map a name to a filesystem location.

Tablespaces are cluster-level objects. Declare them in the cluster objects directory (e.g. production/cluster/tablespaces.dpg). See Project Structure.

Basic tablespace

TABLESPACE fast_ssd LOCATION '/mnt/nvme/pg_data';
TABLESPACE archive  LOCATION '/mnt/hdd/pg_archive';
-- emits
CREATE TABLESPACE "fast_ssd" LOCATION '/mnt/nvme/pg_data';
CREATE TABLESPACE "archive"  LOCATION '/mnt/hdd/pg_archive';

Tablespace with owner

OWNER sits inline in the native CREATE TABLESPACE clause, matching real PostgreSQL’s own grammar exactly — it is not a { } block directive here (unlike Table/View/etc., where OWNER has no place in the native CREATE statement).

TABLESPACE fast_ssd OWNER pg_admin LOCATION '/mnt/nvme/pg_data';
-- emits
CREATE TABLESPACE "fast_ssd" OWNER pg_admin LOCATION '/mnt/nvme/pg_data';

A later change to the declared OWNER emits ALTER TABLESPACE name OWNER TO role.

Using a tablespace

Reference the tablespace name in a table, index, or materialized view declaration:

TABLE events ( ... ) TABLESPACE fast_ssd { ... }
{ INDEXES { idx_events_ts (created_at) TABLESPACE archive; } }

See Tables Overview and Indexes.

Diffing behaviour

ChangeSQLSafety
New tablespaceCREATE TABLESPACESAFE
Owner changedALTER TABLESPACE OWNER TOSAFE
Renamed (RENAMED FROM)ALTER TABLESPACE RENAME TOCAUTION
WITH (...) option changedALTER TABLESPACE SET (...)/RESET (...)CAUTION
LOCATION changedDROP TABLESPACE + CREATE TABLESPACEDESTRUCTIVE
Removed tablespaceDROP TABLESPACEDESTRUCTIVE

LOCATION cannot be changed after creation — any location change requires the full drop-and-recreate path. Dropping a non-empty tablespace fails at the PostgreSQL level; the compiler additionally emits a warning comment noting this.