Skip to main content
Attach a tablespace to a and use it to store s. A tablespace is a directory on the filesystem that allows control over where individual tables and indexes are stored on the filesystem. A common use case is to create a tablespace for a particular storage disk, allowing tables to be stored there. To learn more, see the documentation on tablespaces. can manage a set of tablespaces for each , automatically spreading s across the set of tablespaces attached to a . If a is hash partitioned, tries to place s that belong to the same partition in the same tablespace. Changing the set of tablespaces attached to a may also change the placement behavior. A with no attached tablespaces has its s placed in the database’s default tablespace.

Samples

Attach the tablespace disk1 to the conditions:
SELECT attach_tablespace('disk1', 'conditions');
SELECT attach_tablespace('disk2', 'conditions', if_not_attached => true);

Arguments

NameTypeDefaultRequiredDescription
tablespaceTEXT-Name of the tablespace to attach.
hypertableREGCLASS- to attach the tablespace to.
if_not_attachedBOOLEANfalseSet to true to avoid throwing an error if the tablespace is already attached to the table. A notice is issued instead. Defaults to false.
Tablespaces need to be created before being attached to a . Once created, tablespaces can be attached to multiple s simultaneously to share the underlying disk storage. Associating a regular table with a tablespace using the TABLESPACE option to CREATE TABLE, prior to calling create_hypertable, has the same effect as calling attach_tablespace immediately following create_hypertable.