TimescaleDB多个连续聚合未填充数据

问题描述

我正在尝试创建几个TimescaleDB连续聚合表,如以下链接中的示例所示,但是查询它们时视图中没有数据...

https://docs.timescale.com/latest/using-timescaledb/continuous-aggregates

这是我用于创建连续聚合视图的代码。我创建了一个1小时的间隔,一个2小时的间隔和一个6小时的间隔(即3个连续的聚合视图,显然在TimescaleDB> = v1.4中是允许的)。我正在Postgresql v11.9的Docker容器中使用TimescaleDB v1.7.3。

CREATE VIEW time_series_mv_1_hour_interval
WITH (timescaledb.continuous) AS
SELECT 
    gateway,time_bucket('01:00:00'::interval,timestamp_utc) AS timestamp_utc,avg(spm) AS spm,avg(hyd::integer) AS hyd
FROM public.time_series
GROUP BY 
    gateway,timestamp_utc);

下面是“成功创建”的三个视图的图片

enter image description here

基础表创建如下,并且不断插入新的IoT数据:

create table if not exists public.time_series (
    timestamp_utc timestamp without time zone NOT NULL,gateway text NOT NULL,spm real NULL,hyd bool NULL
    UNIQUE (timestamp_utc,gateway)
);

创建表后,我运行以下命令创建TimescaleDB超表: https://docs.timescale.com/latest/api#create_hypertable

SELECT create_hypertable('public.time_series','timestamp_utc');

然后我先在网关上创建一个智能索引,然后再创建时间:

https://blog.timescale.com/blog/use-composite-indexes-to-speed-up-time-series-queries-sql-8ca2df6b3aaa/ https://docs.timescale.com/latest/using-timescaledb/schema-management#indexing

CREATE INDEX ON public.time_series (gateway,timestamp_utc DESC);

为什么我新创建的连续聚合表/视图中没有数据? 我已经等待了大约16个小时,但是仍然没有数据。

我运行了以下简单查询,但没有返回记录...

SELECT * from time_series_mv_1_hour_interval;

解决方法

解决方案: 重新启动数据库 ,然后滴落级联未填充行的现有连续聚合视图,然后使用完全相同的视图重新创建它们步骤...

我希望我第一次知道是什么原因导致了问题,但至少现在可以了。

-西恩