window_start and window_end.
A materializes aggregates in time buckets. For example,
min, max, average over 1 day worth of data, and is determined by the time_bucket
interval. Therefore, when
refreshing the , only buckets that completely fit within the
refresh window are refreshed. In other words, it is not possible to compute the
aggregate over, for an incomplete bucket. Therefore, any buckets that do not
fit within the given refresh window are excluded.
The function expects the window parameter values to have a time type that is
compatible with the ‘s time bucket expression—for
example, if the time bucket is specified in TIMESTAMP WITH TIME ZONE, then the
start and end time should be a date or timestamp type. Note that a using the TIMESTAMP WITH TIME ZONE type
aligns with the UTC time
zone, so, if window_start and window_end is specified in the local time
zone, any time zone shift relative UTC needs to be accounted for when refreshing
to align with bucket boundaries.
To improve performance for refresh, see
CREATE MATERIALIZED VIEW.
Samples
Refresh theconditions between 2020-01-01 and
2020-02-01 exclusive.
conditions
between 2020-01-01 and 2020-02-01 exclusive, working in 12h intervals:
conditions to refresh between 2020-01-01 and
2020-02-01 exclusive, even if the data has already been refreshed.
Arguments
The syntax is:| Name | Type | Default | Required | Description |
|---|---|---|---|---|
continuous_aggregate | REGCLASS | - | ✔ | The to refresh. |
window_start | INTERVAL, TIMESTAMPTZ, INTEGER | - | ✔ | Start of the window to refresh, has to be before window_end. |
window_end | INTERVAL, TIMESTAMPTZ, INTEGER | - | ✔ | End of the window to refresh, has to be after window_start. |
force | BOOLEAN | FALSE | - | Force refresh every bucket in the time range between window_start and window_end, even when the bucket has already been refreshed. This can be very expensive when a lot of data is refreshed. |
refresh_newest_first | BOOLEAN | TRUE | - | Set to FALSE to refresh the oldest data first. |
window_start and window_end parameters differently,
depending on the type of the time column of the . For s with
TIMESTAMP, TIMESTAMPTZ, and DATE time columns, set the refresh window as
an INTERVAL type. For s with integer-based timestamps, set the
refresh window as an INTEGER type.
A
NULL value for window_start is equivalent to the lowest changed element
in the raw hypertable of the CAgg. A NULL value for window_end is
equivalent to the largest changed element in raw hypertable of the CAgg. As
changed element tracking is performed after the initial CAgg refresh, running
CAgg refresh without window_start and window_end covers the entire time
range.