我在使用timescaledb创建连续聚合时出错,该数据库使用postgres物化视图:
connection = psycopg2.connect(DATABASE_URI)
cursor = connection.cursor()
cursor.execute(
"""CREATE MATERIALIZED VIEW quotes_1h WITH
(timescaledb.continuous)
AS
SELECT ticker, time_bucket('1h', time) as hour,
min(close) as low,
max(close) as high,
first(close, time) as open,
last(close, time) as close
FROM quotes
GROUP BY
ticker, time_bucket('1h', time);""")
connection.commit()
错误: psycopg2.errors.ActiveSqlTransaction:创建物化视图。。。WITH DATA不能在事务块内运行
我已经设置了自动提交,但没有帮助
修正了它:
TimescaleDB目前不支持在同一事务中创建连续聚合并将其物化。因此,有两种选择:
WITH NO DATA
和refreshing separately或通过policy来具体化连续聚合李>第二种情况是:
相关问题 更多 >
编程相关推荐