| api_name | recompress_chunk() | ||||
|---|---|---|---|---|---|
| excerpt | Recompress a chunk that had new data inserted after compression | ||||
| topics |
|
||||
| keywords |
|
||||
| tags |
|
||||
| api |
|
||||
| products |
|
import Deprecated2180 from "versionContent/_partials/_deprecated_2_18_0.mdx";
Superseded by convert_to_columnstore(). However, compression APIs are still supported, you do not need to migrate to the hypercore APIs.
Recompresses a compressed chunk that had more data inserted after compression.
recompress_chunk(
chunk REGCLASS,
if_not_compressed BOOLEAN = false
)You can also recompress chunks by
running the job associated with your compression policy.
recompress_chunk gives you more fine-grained control by
allowing you to target a specific chunk.
recompress_chunk is deprecated since $TIMESCALE_DB v2.14 and will be removed in the future.
The procedure is now a wrapper which calls compress_chunk
instead of it.
recompress_chunk is implemented as an SQL procedure and not a function. Call
the procedure with CALL. Don't use a SELECT statement.
recompress_chunk only works on chunks that have previously been compressed. To compress a
chunk for the first time, use compress_chunk.
Recompress the chunk timescaledb_internal._hyper_1_2_chunk:
CALL recompress_chunk('_timescaledb_internal._hyper_1_2_chunk');| Name | Type | Description |
|---|---|---|
chunk |
REGCLASS |
The chunk to be recompressed. Must include the schema, for example _timescaledb_internal, if it is not in the search path. |
| Name | Type | Description |
|---|---|---|
if_not_compressed |
BOOLEAN |
If true, prints a notice instead of erroring if the chunk is already compressed. Defaults to false. |
In $TIMESCALE_DB 2.6.0 and above, recompress_chunk is implemented as a procedure.
Previously, it was implemented as a function. If you are upgrading to
$TIMESCALE_DB 2.6.0 or above, therecompress_chunk
function could cause an error. For example, trying to run SELECT recompress_chunk(i.show_chunks, true) FROM... gives the following error:
ERROR: recompress_chunk(regclass, boolean) is a procedureTo fix the error, use CALL instead of SELECT. You might also need to write a
procedure to replace the full functionality in your SELECT statement. For
example:
DO $$
DECLARE chunk regclass;
BEGIN
FOR chunk IN SELECT format('%I.%I', chunk_schema, chunk_name)::regclass
FROM timescaledb_information.chunks
WHERE is_compressed = true
LOOP
RAISE NOTICE 'Recompressing %', chunk::text;
CALL recompress_chunk(chunk, true);
END LOOP;
END
$$;