If you need to modify or add a lot of data to a chunk that has already been compressed, you should decompress the chunk first. This is especially useful for backfilling old data.

Important

Before decompressing chunks, stop any compression policy on the hypertable you are decompressing. You can use SELECT alter_job(JOB_ID, scheduled => false); to prevent scheduled execution. When you finish backfilling or updating data, turn the policy back on. The database automatically recompresses your chunks in the next scheduled job.

NameTypeDescription
chunk_nameREGCLASSName of the chunk to be decompressed.
NameTypeDescription
if_compressedBOOLEANDisabling this will make the function error out on chunks that are not compressed. Defaults to true.

Decompress a single chunk:

SELECT decompress_chunk('_timescaledb_internal._hyper_2_2_chunk');

Decompress all compressed chunks in a hypertable named metrics:

SELECT decompress_chunk(c, true) FROM show_chunks('metrics') c;

Keywords

Found an issue on this page?Report an issue or Edit this page in GitHub.