Skip to content

Drop data from continuous aggregates

Drop a view or raw data from a continuous aggregate or its underlying hypertable

You can remove a continuous aggregate view, trim raw rows from the source hypertable, or rely on refresh plus retention policies to keep coarse long-term aggregates while dropping detailed history.

Watch for retention rules that delete raw hypertable rows your continuous aggregate still needs to rebuild or refresh correctly.

You can drop a continuous aggregate view using the DROP MATERIALIZED VIEW command. This command also removes refresh policies defined on the continuous aggregate. It does not drop the data from the underlying hypertable.

DROP MATERIALIZED VIEW view_name;

If you drop data from a hypertable used in a continuous aggregate it can lead to problems with your continuous aggregate view. In many cases, dropping underlying data replaces the aggregate with NULL values, which can lead to unexpected results in your view.

You can drop data from a hypertable using drop_chunks in the usual way, but before you do so, always check that the chunk is not within the refresh window of a continuous aggregate that still needs the data. This is also important if you are manually refreshing a continuous aggregate. Calling refresh_continuous_aggregate on a region containing dropped chunks recalculates the aggregate without the dropped data.

If a continuous aggregate is refreshing when data is dropped because of a retention policy, the aggregate is updated to reflect the loss of data. If you need to retain the continuous aggregate after dropping the underlying data, set the start_offset value of the aggregate policy to a smaller interval than the drop_after parameter of the retention policy.

For more information, see the data retention documentation.