Skip to main content
You use tablespaces to determine the physical location of the tables and indexes in your database. In most cases, you want to use faster storage to store data that is accessed frequently, and slower storage for data that is accessed less often. s consist of a number of s, and each can be located in a specific tablespace. This allows you to grow your s across many disks. When you create a new , a tablespace is automatically selected to store the ‘s data. You can attach and detach tablespaces on a . When a disk runs out of space, you can detach the full tablespace from the , and than attach a tablespace associated with a new disk. To see the tablespaces for you , use the show_tablespaces command.

How hypertable chunks are assigned tablespaces

A can be partitioned in multiple dimensions, but only one of the dimensions is used to determine the tablespace assigned to a particular . If a 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 s have s co-located according to hash partition, as long as the list of tablespaces attached to the 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. s that are only time-partitioned add new partitions continuously, and therefore have s assigned to tablespaces in a way similar to round-robin.
It is possible to attach more tablespaces than there are partitions for the . In this case, some tablespaces remain unused until others are detached or additional partitions are added. This is especially true for hash-partitioned tables.

Automatic tablespace management

Moving older data to a different tablespace can help you save on storage costs. supports automatic tablespace management by providing the move_chunk function to move chunks between tablespaces. To schedule the moves automatically, you can write a custom .
On , use tiered storage which handles this by providing a tiering policy API to move data to low-cost object storage backed by Amazon S3.
To implement automatic moving with a :
  1. Create a procedure that moves chunks to a different tablespace This procedure moves s to a different tablespace if they contain data older than the lag parameter.
  2. Register the job to run daily In the config, set hypertable to metrics to implement automatic moves on the metrics . Set lag to 12 months to move s containing data older than 12 months. Set tablespace to the destination tablespace.