example, and
compress chunks older than three days.
-
Select chunks to compress
At the psql prompt, select all chunks in the table
examplethat are older than three days:This returns a list of chunks. Take note of the chunks’ names:
-
Compress the chunk
At the psql prompt, compress the chunk:
-
Check the compression results
Check the results of the compression with this command:
The results show the chunks for the given , their compression status, and some other statistics:
- Repeat for all chunks Repeat for all chunks you want to compress.
Manually compress chunks in a single command
Alternatively, you can select the chunks and compress them in a single command by using the output of theshow_chunks
command to compress each one. For example, use this command to compress chunks between one and three weeks old if they
are not already compressed:
Roll up uncompressed chunks when compressing
In v2.9 and later, you can roll up multiple uncompressed chunks into a previously compressed chunk as part of your compression procedure. This allows you to have much smaller uncompressed chunk intervals, which reduces the disk space used for uncompressed data. For example, if you have multiple smaller uncompressed chunks in your data, you can roll them up into a single compressed chunk. To roll up your uncompressed chunks into a compressed chunk, alter the compression settings to set the compress chunk time interval and run compression operations to roll up the chunks while compressing.The default setting of
compress_orderby is 'time DESC' (the descending or DESC command is used to sort the data
returned in ascending order), which causes chunks to be re-compressed many times during the rollup, possibly leading to
a steep performance penalty. Set timescaledb.compress_orderby = 'time ASC' to avoid this penalty.<time_interval> of the compressed chunk could be two weeks or six weeks, but not one
month.