【发布时间】:2019-06-20 06:23:44
【问题描述】:
我有这个带有超表的series 表。我想对该表中的数据进行不同的连续聚合。
CREATE TABLE series (
time TIMESTAMPTZ PRIMARY KEY,
value INTEGER
);
SELECT create_hypertable('series', 'time');
CREATE VIEW mat_view1
WITH (timescaledb.continuous) AS
SELECT time_bucket('1 day', time) AS day,
AVG(value)
FROM series
GROUP BY day;
CREATE VIEW mat_view2
WITH (timescaledb.continuous) AS
SELECT time_bucket('1 week', time) AS week,
COUNT(value)
FROM series
GROUP BY week;
但似乎在 PostgreSQL 11 中是不可能的 - 这是我在运行上面的查询时得到的:
ERROR: hypertable already has a continuous aggregate
RECOMMENDATION: hypertables currently only support a single continuous aggregate. Drop the other continuous aggreagate to add a new one.
甚至不可能在同一张表上创建不同的超表。
ERROR: hypertable already has a continuous aggregate
RECOMMENDATION: hypertables currently only support a single continuous aggregate. Drop the other continuous aggreagate to add a new one.
是否可以解决此限制?或者我应该使用另一种方法(例如,为每个连续聚合复制series 表:-x)?
【问题讨论】:
标签: sql postgresql-11 timescaledb