【问题标题】:Function add_compression_policy not found with TimescaleDBTimescaleDB 找不到函数 add_compression_policy
【发布时间】:2020-12-28 23:49:13
【问题描述】:

我正在运行最新版本的 TimescaleDB。

在文档中我发现了这个:https://docs.timescale.com/latest/using-timescaledb/compression#quick-start

当我跑步时:

CREATE TABLE con_details (LIKE deprecated_consumption_details INCLUDING DEFAULTS INCLUDING CONSTRAINTS INCLUDING INDEXES);
    
SELECT create_hypertable('con_details', 'date');
    
ALTER TABLE con_details SET (
  timescaledb.compress,
  timescaledb.compress_segmentby = 'meter_id'
);
    
SELECT add_compression_policy('con_details', INTERVAL '7 days');

最后一行报错:

SQL Error [42883]: ERROR: function add_compression_policy(unknown, interval) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 9

还有文档中的其他功能,例如:

SELECT * FROM hypertable_detailed_size('con_details');

给我错误:

ERROR: function hypertable_detailed_size(unknown) does not exist

TimescaleDB 扩展当然已启用(创建和查询 Hypertable 工作正常...)

【问题讨论】:

  • 您使用哪个版本的 TimescaleDB?

标签: timescaledb


【解决方案1】:

简而言之,add_compression_policy 在 TimescaleDB 2.0 的 API 中,而早期版本(例如 1.7.4)有add_compress_chunks_policy。而hypertable_detailed_size 在 2.0 之前不存在。

TimescaleDB 2.0 是自 12 月 21 日以来的最新版本,引入了breaking changes in its API 的数量,政策受到很大影响。例如,add_compress_chunks_policy 被重命名为 add_compression_policy,它的参数也被重命名。

The documentation默认显示最新的API,而很多用户可能使用1.7,这需要使用different version of documentation。 Timescale 文档页面允许选择与主要 TimescaleDB 版本相对应的文档版本:

【讨论】:

  • 你是 100% 正确的。我的印象是我使用的是 AWS 上的 AMI 声明的 v2.0.0(TimescaleDB 2.0.0(PostgreSQL 12)-Ubuntu 18.04(EBS 支持)-ami-06479c10b25555960)。不幸的是,它是 v1.7.4。为什么会这样是另一个与这个问题无关的问题。
猜你喜欢
  • 2018-01-22
  • 2021-06-19
  • 2020-11-27
  • 2022-10-05
  • 1970-01-01
  • 2019-09-09
  • 2012-01-07
  • 2019-05-19
  • 2020-10-02
相关资源
最近更新 更多