Manually drop chunks
Manually drop chunks from your hypertables based on time value
Drop chunks manually by time value. For example, drop chunks containing data older than 30 days.
Dropping chunks manually is a one-time operation. To automatically drop chunks as they age, set up a data retention policy.
Drop chunks older than a certain date
Section titled “Drop chunks older than a certain date”To drop chunks older than a certain date, use the drop_chunks
function. Provide the name of the hypertable to drop chunks from, and a time
interval beyond which to drop chunks.
For example, to drop chunks with data older than 24 hours:
SELECT drop_chunks('conditions', INTERVAL '24 hours');Drop chunks between 2 dates
Section titled “Drop chunks between 2 dates”You can also drop chunks between 2 dates. For example, drop chunks with data between 3 and 4 months old.
Supply a second INTERVAL argument for the newer_than cutoff:
SELECT drop_chunks( 'conditions', older_than => INTERVAL '3 months', newer_than => INTERVAL '4 months')Drop chunks in the future
Section titled “Drop chunks in the future”You can also drop chunks in the future, for example, to correct data with the
wrong timestamp. To drop all chunks that are more than 3 months in the
future, from a hypertable called conditions:
SELECT drop_chunks( 'conditions', newer_than => now() + INTERVAL '3 months');Learn more
Section titled “Learn more”- Create a data retention policy: Automate chunk deletion based on age.
- Understand chunks: How chunks work and why they matter.
drop_chunks()reference: Full API reference with all parameters.show_chunks()reference: List chunks before dropping them.