我使用timescaledb 2.9.3,并且有一个简单的超表:
CREATE TABLE metrics
(
time TIMESTAMP NOT NULL,
value INT
);
SELECT create_hypertable('metrics', 'time');
我插入了一些数据并创建了两个仅物化的视图:
CREATE MATERIALIZED VIEW IF NOT EXISTS metrics_hourly
WITH (timescaledb.continuous, timescaledb.materialized_only=true)
AS
SELECT time_bucket('1 hour', time) as hour, sum(value)
FROM metrics
GROUP BY hour
WITH NO DATA;
CREATE MATERIALIZED VIEW IF NOT EXISTS metrics_monthly
WITH (timescaledb.continuous, timescaledb.materialized_only=true)
AS
SELECT time_bucket('1 month', time) as month, sum(value)
FROM metrics
GROUP BY month
WITH NO DATA;
当我尝试使用更新metrics_hourly
时
call refresh_continuous_aggregate('metrics_hourly', NULL, NULL);
还可以,更新得很好。
当我尝试以同样的方式更新metrics_monthly
时
call refresh_continuous_aggregate('metrics_monthly', NULL, NULL);
我有一个错误:
ERROR: timestamp out of range
SQL state: 22008
我应该指定start或end以使其工作,例如:
call refresh_continuous_aggregate('metrics_monthly', '2021-01-01', NULL);
为什么我不能使用开始和结束都为空的每月查看?
1条答案
按热度按时间5kgi1eie1#
您可以只提供
'-infinite'
和now()
来刷新它: