我已经将大量的历史数据加载到时间升级表中。
CREATE TABLE quotes (
"time" timestamp NULL,
symbol_id int4 NULL,
"open" numeric(14,6) NULL,
"close" numeric(14,6) NULL,
high numeric(14,6) NULL,
low numeric(14,6) NULL,
volume int8 NULL,
CONSTRAINT quotes_ts_pkey PRIMARY KEY (symbol_id, "time")
);
SELECT create_hypertable('quotes', 'time', 'symbol_id', 1, create_default_indexes => false);
ALTER TABLE quotes SET (
timescaledb.compress,
timescaledb.compress_segmentby = 'symbol_id'
);
SELECT add_compress_chunks_policy('quotes', INTERVAL '7 days');之后,我将数据插入到表中:
insert into quotes ("time", data_id, "open", "close", high, low, volume)
select "time", symbol_id, "open", "close", high, low, volume
from source_schema.quotes;我看到哪些数据没有被压缩。
SELECT * FROM timescaledb_information.compressed_chunk_stats
ORDER BY compression_status, hypertable_name, chunk_name;此外,我还可以使用必须压缩的旧数据来选择块(这是我的预期)。
SELECT show_chunks('quotes', older_than => INTERVAL '7 days');如果我试图压缩块,它会很好地工作:
SELECT compress_chunk('_timescaledb_internal._hyper_1_59_chunk');但是,如何根据指定的策略启动内部时标b作业来自动压缩块呢?
发布于 2020-07-03 16:55:59
“选择add_compress_chunks_policy(‘引号’,间隔'7天‘);”应该开始对任何7天以上的块自动处理。(也就是说,块的末尾必须是7天前的>=。)
还可以看到压缩数据或后台辅助任务的信息视图:
https://docs.timescale.com/latest/api#timescaledb_information-compressed_hypertable_stats https://docs.timescale.com/latest/api#timescaledb_information-compressed_chunk_stats https://docs.timescale.com/latest/api#timescaledb_information-policy_stats
不能准确地从您提供的信息中确定为什么您没有看到压缩数据。在slack.timescale.com的社区空闲通道上帮助调试可能更容易。干杯!
https://stackoverflow.com/questions/62719619
复制相似问题