I created a continuous aggregate with time bucket as 5 mins. While adding policy I gave policy as below:
SELECT add_continuous_aggregate_policy('public.test_five_min_view',
start_offset => INTERVAL '1 hour',
end_offset => INTERVAL '0 minute',
schedule_interval => INTERVAL '1 hour');
On checking logs I found that it is by default skipping 5 mins.
2023-08-03 12:12:50.924 UTC [2771] LOG: refreshing continuous aggregate "test_five_min_view" in window [ 2023-08-03 11:15:00+00, 2023-08-03 12:10:00+00 ]
The expectation was that it will start at 11:10:00 to 12:10:00, which is not the case now.
start_offset
: the start of the refresh window relative to when the policy runs
end_offset
: the end of the refresh window relative to when the policy runs
Both are relative to policy run time. In your case policy ran at 2023-08-03 12:12:50.924
. To avoid the gaps in aggregate, choose start_offset
larger than schedule_interval
(consider your project historic data filling) and timescale does aggregations only for the buckets where there is a data change.