提问者:小点点

TimasceDB多个连续聚合没有填充数据


我正在尝试创建几个TimasceDB连续聚合表,就像下面链接中的示例一样,但是当我查询它们时,视图中没有数据…

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

这是我创建连续聚合视图的代码。我创建了一个1小时间隔、一个2小时间隔和一个6小时间隔(即3个连续聚合视图,这显然在TimasceDB中是允许的

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, 
    time_bucket('01:00:00'::interval, timestamp_utc);

底层表的创建如下,并且不断插入新的物联网数据:

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)
);

创建表后,我运行以下命令来创建TimasceDB超表: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;

共1个答案

匿名用户

解决方案:将未填充行的现有连续聚合视图级联,并使用完全相同的步骤重新创建它们……

我希望我第一次知道是什么导致了这个问题,但至少现在它起作用了。

-肖恩