Skip to main content
When you are working with s, you can drop a view, or you can drop raw data from the underlying or from the itself. A combination of refresh and data retention policies can help you downsample your data. This lets you keep historical data at a lower granularity than recent data. However, you should be aware if a retention policy is likely to drop raw data from your that you need in your . To simplify the process of setting up downsampling, you can use the visualizer and code generator.

Drop a continuous aggregate view

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

Drop raw data from a hypertable

If you drop data from a used in a it can lead to problems with your 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 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 that still needs the data. This is also important if you are manually refreshing a . Calling refresh_continuous_aggregate on a region containing dropped chunks recalculates the aggregate without the dropped data. If a 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 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.

Set up downsampling and data retention

Maximize your storage by keeping downsampled historical data and dropping raw data. Once you’ve created a , you can automatically downsample your data by configuring the following policies:
  1. Refresh policy: control when and how often your is updated
  2. Raw data retention policy: control how long to keep data in the underlying
  3. Downsampled data retention policy: control how long to keep data in the
The following widget creates a valid policy for you. Run the generated SQL in your . Dropping raw data within your refresh interval can cause data loss. To fix, only drop raw data older than your refresh interval.