在TimescaleDB中,我有一个包含每日平均值的连续集料,所以桶的大小是1天:
CREATE MATERIALIZED VIEW sensors_daily
WITH (timescaledb.continuous, timescaledb.materialized_only=true)
AS
SELECT time_bucket_gapfill('1d', time) AS time,
id,
average(time_weight('LOCF', time, sensor1)) AS sensor1,
average(time_weight('LOCF', time, sensor2)) AS sensor2,
FROM sensors
GROUP BY time_bucket('1d', time), id;我还创建了一个连续总量政策来保存过去的30天,并每天更新它。看起来是这样的:
SELECT add_continuous_aggregate_policy('sensors_daily',
start_offset => INTERVAL '30 days',
end_offset => INTERVAL '1 day',
schedule_interval => INTERVAL '1 day');现在我的问题是:,我没有得到昨天的数据,也没有包含昨天的数据。,我也没有得到前天的数据。风景总是在三天后。
当我查询下午2022-02-17的最新时间时
select max(time) from sensors_daily;我得到了14号
2022-02-14 01:00:00.000 +0100通过
SELECT * FROM timescaledb_information.job_stats;我看到它在午夜后每天运行得很成功。
last_run_started_at: 2022-02-17 00:12:07.208 +0100
last_successful_finish: 2022-02-17 00:12:51.699 +0100
last_run_status: Success
last_run_duration: 00:00:44.491458
next_start: 2022-02-18 00:12:51.699 +0100,我需要更改什么才能将日常数据更新到并包括昨天?
编辑2022-02-18可能很重要:传感器源超表中的时间戳是TIMESTAMPTZ (带时区的时间戳,德语)。
发布于 2022-04-05 12:29:18
我最终通过在连续聚合策略中将end_offset和schedule_interval从1 day减少到6 hours来解决这个问题。
https://stackoverflow.com/questions/71160956
复制相似问题