Skip to content

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.

Note

Dropping chunks manually is a one-time operation. To automatically drop chunks as they age, set up a data retention policy.

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');

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'
)

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'
);