To automate the archival of data not actively accessed, create a tiering policy that
automatically moves data to the object storage tier. Any chunks that only contain data
older than the
move_after threshold are moved. This works similarly to a
data retention policy, but chunks are moved rather than deleted.
The tiering policy schedules a job that runs periodically to migrate eligible chunks. The migration is asynchronous. The chunks are tiered once they appear in the timescaledb_osm.tiered_chunks view. Tiering does not influence your ability to query the chunks.
To add a tiering policy, use the
SELECT add_tiering_policy(hypertable REGCLASS, move_after INTERVAL);
In this example, you use a hypertable called example, and tier chunks older than three days.
- At the psql prompt, select the hypertable and duration:
SELECT add_tiering_policy('example', INTERVAL '3 days');
To remove an existing tiering policy, use the
SELECT remove_tiering_policy(hypertable REGCLASS, if_exists BOOL = false);
- At the psql prompt, select the hypertable to remove the policy from:
If you remove a tiering policy, the removal automatically prevents scheduled chunks from being tiered in the future. Any chunks that were already tiered won't be untiered automatically. You can use the untier_chunk procedure to untier chunks to local storage that have already been tiered.
Tiering a chunk schedules the chunk for migration to the object storage tier but, won't be tiered immediately. It may take some time tiering to complete. You can continue to query a chunk during migration.
To see which chunks are tiered into the object storage tier, use the
SELECT * FROM timescaledb_osm.tiered_chunks;
If you need to untier your data, see the manually untier data section.
Found an issue on this page?Report an issue!