Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Tablespaces

Tablespaces place relation files outside the cluster’s main data directory.

CREATE TABLESPACE fast LOCATION '/srv/amphi-fast';
CREATE TABLE events (id int4, payload text) TABLESPACE fast;
ALTER TABLESPACE fast RENAME TO archive;
DROP TABLESPACE archive;

LOCATION must be an absolute path writable by the Amphi process. The external directory receives a cluster-controlled subdirectory; do not use the cluster data directory itself. pg_default is the internal tablespace used when no tablespace is specified. Creating, renaming, and dropping tablespaces require an administrative session.

ALTER TABLE ... SET TABLESPACE moves existing heap relations to a new physical generation, preserving heap, TOAST, and indexes. The operation requires an administrative session; non-heap relations are not supported yet. Restore-time path mapping is available with an explicit option:

amprestore --tablespace fast=/srv/amphi-fast dump.sql

Repeat the option for multiple tablespaces. Tablespaces not present in the map keep the LOCATION recorded in the dump.

DROP TABLESPACE requires an empty tablespace. Amphi does not provide CASCADE for this command; remove associated relations explicitly first. CREATE TABLESPACE and DROP TABLESPACE cannot run inside a transaction. When an empty tablespace is removed, Amphi removes its ownership marker; unknown content prevents the operation.