Skip to main content
Early access Alter refresh, , or data retention policies on a . The altered and retention policies apply to the , not to the original .
timescaledb_experimental.alter_policies(
     relation REGCLASS,
     if_exists BOOL = false,
     refresh_start_offset "any" = NULL,
     refresh_end_offset "any" = NULL,
     compress_after "any" = NULL,
     drop_after "any" = NULL
) RETURNS BOOL

Samples

Given a named example_continuous_aggregate with an existing policy, alter the policy to compress data older than 16 days:
SELECT timescaledb_experimental.alter_policies(
    'continuous_agg_max_mat_date',
    compress_after => '16 days'::interval
);

Arguments

The syntax is:
CALL alter_policies(
    relation = '<view_name>',
    refresh_start_offset = <interval>,
    refresh_end_offset = <interval>,
    compress_after = <interval>,
    refresh_schedule_interval = <interval>
);
NameTypeDefaultRequiredDescription
relationREGCLASS-The that you want to alter policies for
if_not_existsBOOLfalse-When true, prints a warning instead of erroring if the policy doesn’t exist.
refresh_start_offsetINTERVAL or INTEGER--The start of the refresh window, expressed as an offset from the policy run time.
refresh_end_offsetINTERVAL or INTEGER--The end of the refresh window, expressed as an offset from the policy run time. Must be greater than refresh_start_offset.
compress_afterINTERVAL or INTEGER-- s are compressed into the if they exclusively contain data older than this interval.
drop_afterINTERVAL or INTEGER-- s are dropped if they exclusively contain data older than this interval.
For arguments that could be either an INTERVAL or an INTEGER, use an INTERVAL if your time bucket is based on timestamps. Use an INTEGER if your time bucket is based on integers.

Returns

Returns true if successful.