'TimescaleDB high disk space usage despite compression activated

I have a TimescaleDB database running on Docker (which is running on Ubuntu). As you can guess, I store a lot of time-series data in it and to save disk space I activated a compression policy:

ALTER TABLE measurements SET (
  timescaledb.compress,
  timescaledb.compress_orderby = 'time DESC',
  timescaledb.compress_segmentby = 'device'
)

SELECT add_compression_policy('measurements', INTERVAL '2 weeks')

and if I check the compression stats i get the result I expect:

  • before compression --> 81GB
  • after compression --> 3900MB

Until here it's all fine, except it does not free up actual disk space and the Docker folder that contains the TimescaleDB files is growing as if compression was never activated in the first place.

VACUUMing the whole DB has no effect, except for taking up an additional 1GB of disk space.

EDIT:

by disk space I mean the specific fs directory where the timescaleDB volume is mounted, where the database files are stored on the host machine.



Solution 1:[1]

It turns out that everything worked fine, I was just tricked by what the compression_stats were telling me.

In the end the compression was active but the chunks were not old enough so they weren't compressed yet, just pending to be compressed.

We noticed it by manually checking chunks status.

Thanks to everyone who commented.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 morphineglelly