Convert continuous aggregates to the columnstore
Compress a continuous aggregate to the columnstore to save storage space while making sure the data is still available for your analytical workloads
To save on storage costs, you use hypercore to downsample historical data stored in continuous aggregates. After you
enable columnstore on a MATERIALIZED VIEW, you set a
columnstore policy. This policy defines the intervals when chunks in a continuous aggregate
are compressed as they are converted from the rowstore to the columnstore.
Columnstore works in the same way on hypertables and continuous aggregates. When you enable
columnstore with no other options, your data is segmented by the groupby columns
in the continuous aggregate, and ordered by the time column. Real-time aggregate
is disabled by default.
Configure columnstore on continuous aggregates
Section titled “Configure columnstore on continuous aggregates”For an existing continuous aggregate:
- Enable columnstore on a continuous aggregate
Set
timescaledb.enable_columnstore = truewhen you alter the view:ALTER MATERIALIZED VIEW <cagg_name> set (timescaledb.enable_columnstore = true);To disable the columnstore, set
timescaledb.enable_columnstore = false. - Set columnstore policies on the continuous aggregate
Before you set up a columnstore policy on a continuous aggregate, you first set the refresh policy. To prevent refresh policies from failing, set the columnstore policy interval so that actively refreshed regions are not compressed. For example:
-
Set the refresh policy:
SELECT add_continuous_aggregate_policy('<cagg_name>',start_offset => INTERVAL '30 days',end_offset => INTERVAL '1 day',schedule_interval => INTERVAL '1 hour'); -
Set the columnstore policy. The
afterparameter must be greater than the value ofstart_offsetin the refresh policy:CALL add_columnstore_policy('<cagg_name>', after => INTERVAL '45 days');
-