TimescaleDB 未找到函数 add_compression_policy

Function add_compression_policy not found with TimescaleDB

我运行正在使用最新版本的 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 工作正常...)

简而言之,add_compression_policy is in the API of TimescaleDB 2.0, while earlier versions, e.g., 1.7.4 have add_compress_chunks_policy. And hypertable_detailed_size 在 2.0 之前不存在。

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

The documentation shows latest API by default, while many users are likely to use 1.7, which requires to use different version of documentation。 Timescale 文档页面允许选择与主要 TimescaleDB 版本相对应的文档版本: