【问题标题】:Timescale DB manual compression disk space not reducedTimescale DB 手动压缩磁盘空间未减少
【发布时间】:2021-11-17 18:12:19
【问题描述】:

当我们进行手动压缩时,它并没有减少可用空间,而是增加了。

压缩后,我们也执行了vacuum命令。

执行回复查询后的屏幕截图。 screenshot-with-replied-queries

样本数据 sample-data

使用以下查询添加压缩

ALTER TABLE data_table SET (timescaledb.compress,timescaledb.compress_segmentby = 'insert_time_stamp');

SELECT compress_chunk(i) FROM show_chunks('data_table', old_than => INTERVAL '10 days') i;

【问题讨论】:

  • 您能分享几行数据示例吗?

标签: timescaledb


【解决方案1】:

你检查过你压缩了多少块吗?

select total_chunks, number_compressed_chunks, pg_size_pretty(before_compression_total_bytes), pg_size_pretty(after_compression_total_bytes) from hypertable_compression_stats('pages');
┌──────────────┬──────────────────────────┬────────────────┬────────────────┐
│ total_chunks │ number_compressed_chunks │ pg_size_pretty │ pg_size_pretty │
├──────────────┼──────────────────────────┼────────────────┼────────────────┤
│          107 │                       19 │ 1883 MB        │ 543 MB         │
└──────────────┴──────────────────────────┴────────────────┴────────────────┘
(1 row)

您还可以检查单个块:

select  pg_size_pretty(sum(before_compression_total_bytes)),
   pg_size_pretty(sum(after_compression_total_bytes))
from chunk_compression_stats('pages') 
where compression_status = 'Compressed';
┌────────────────┬────────────────┐
│ pg_size_pretty │ pg_size_pretty │
├────────────────┼────────────────┤
│ 1883 MB        │ 543 MB         │
└────────────────┴────────────────┘
(1 row)

【讨论】:

  • 感谢您的回复。我查了一下,是2块。但是,磁盘空间并没有减少。再次添加问题中的屏幕截图。
  • 感谢分享示例数据和屏幕截图。我认为您可能需要使用更好的timescaledb.compress,timescaledb.compress_segmentby。您可以看到您在那里使用了时间戳列,并且它正在创建可能不适合分组的片段。尝试使用具有更好基数的列。就像某些类别或在行上重复的东西,可以进一步用作查询中的一种索引。如果您的数据每秒都在变化并按它进行分段,那么分段中的元数据将比数据本身更多。
猜你喜欢
  • 2019-06-10
  • 1970-01-01
  • 2021-01-29
  • 1970-01-01
  • 2019-11-14
  • 1970-01-01
  • 2015-06-30
  • 2018-11-10
  • 2022-06-29
相关资源
最近更新 更多