Versions:

move_chunk()
Community

TimescaleDB allows you to move data and indexes to different tablespaces. This allows you to move data to more cost-effective storage as it ages.

The move_chunk function acts like a combination of the PostgreSQL CLUSTER command and PostgreSQL ALTER TABLE...SET TABLESPACE commands. Unlike these PostgreSQL commands, however, the move_chunk function uses lower lock levels so that the chunk and hypertable are able to be read for most of the process. This comes at a cost of slightly higher disk usage during the operation. For a more detailed discussion of this capability, see the Data Tiering documentation.

Required arguments

NameTypeDescription
chunkREGCLASSName of chunk to be moved
destination_tablespaceTEXTTarget tablespace for chunk being moved
index_destination_tablespaceTEXTTarget tablespace for index associated with the chunk you are moving

Optional arguments

NameTypeDescription
reorder_indexREGCLASSThe name of the index (on either the hypertable or chunk) to order by
verboseBOOLEANSetting to true will display messages about the progress of the move_chunk command. Defaults to false.

Sample usage

SELECT move_chunk(
  chunk => '_timescaledb_internal._hyper_1_4_chunk',
  destination_tablespace => 'tablespace_2',
  index_destination_tablespace => 'tablespace_3',
  reorder_index => 'conditions_device_id_time_idx',
  verbose => TRUE
);

Found an issue on this page?

Report an issue!

Related Content