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 add_tiering_policy
function:
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 remove_tiering_policy
function:
SELECT remove_tiering_policy(hypertable REGCLASS, if_exists BOOL = false);
- At the psql prompt, select the hypertable to remove the policy from:
SELECT remove_tiering_policy('example');
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.
Info
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 tiered_chunks
informational view:
SELECT * FROM timescaledb_osm.tiered_chunks;
If you need to untier your data, see the manually untier data section.
Keywords
Found an issue on this page?
Report an issue!