Improve storage performance using tablespaces
Store database objects in specific physical locations on disk using tablespaces for PostgreSQL hypertable chunks
Tablespaces pin tables and indexes to specific disk paths so you can put hot data on fast volumes and colder data on cheaper ones.
A hypertable stores each chunk in a tablespace you choose, so one logical table can span many disks. New chunks pick a tablespace according to your configuration.
You can attach and detach tablespaces on a hypertable. When a disk runs
out of space, you can detach the full tablespace from the
hypertable, and then attach a tablespace associated with a
new disk. To see the tablespaces for your hypertable, use the
show_tablespaces
command.
How hypertable chunks are assigned tablespaces
Section titled “How hypertable chunks are assigned tablespaces”A hypertable can be partitioned in multiple dimensions, but only one of the dimensions is used to determine the tablespace assigned to a particular hypertable chunk. If a hypertable has one or more hash-partitioned, or space, dimensions, it uses the first hash-partitioned dimension. Otherwise, it uses the first time dimension.
This strategy ensures that hash-partitioned hypertables have chunks co-located according to hash partition, as long as the list of tablespaces attached to the hypertable remains the same. Modulo calculation is used to pick a tablespace, so there can be more partitions than tablespaces. For example, if there are two tablespaces, partition number three uses the first tablespace.
Hypertables that are only time-partitioned add new partitions continuously, and therefore have chunks assigned to tablespaces in a way similar to round-robin.
It is possible to attach more tablespaces than there are partitions for the hypertable. In this case, some tablespaces remain unused until others are detached or additional partitions are added. This is especially true for hash-partitioned tables.