Moving older data to a different tablespace can help you save on
storage costs. Timescale supports automatic tablespace management by providing
move_chunk function to move chunks between tablespaces. To schedule the
moves automatically, you can write a user-defined action.
Create a procedure that moves chunks to a different tablespace if they contain data older than the
Register the job to run daily. In the config, set
metricsto implement automatic chunk moves on the
lagto 12 months to move chunks containing data older than 12 months. Set
tablespaceto the destination tablespace.
This procedure uses PostgreSQL's regular
ALTER TABLE ... SET TABLESPACE syntax to move chunks. You could also write the procedure using TimescaleDB's
move_chunk function. The
move_chunk function reorders the data as part of the move, which makes subsequent queries faster. It also requires lower lock levels, so the chunk remains available for reads during the move.
Found an issue on this page?Report an issue!