【问题标题】:TimescaleDB multiple continuous aggregates not filling up with dataTimescaleDB 多个连续聚合未填满数据
【发布时间】:2020-12-31 11:38:59
【问题描述】:

我正在尝试创建几个 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, 
    time_bucket('01:00:00'::interval, timestamp_utc);

这是我“成功创建”的三个视图的图片:

基础表创建如下,并且不断插入新的 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;

【问题讨论】:

  • 如果您再次遇到 caggs 不是最新的问题,您可以查看 timescaledb_information.continuous_aggregate_stats view 以查看最后一个作业是否已运行并且是否成功。日志中也可能有信息。

标签: timescaledb


【解决方案1】:

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

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

-肖恩

【讨论】:

    猜你喜欢
    • 2021-10-03
    • 2021-04-26
    • 1970-01-01
    • 2020-12-20
    • 2021-11-29
    • 2021-10-29
    • 2021-11-21
    • 1970-01-01
    • 2021-11-07
    相关资源
    最近更新 更多