drop_chunk()
Drop a single chunk
Drop a single chunk from a hypertable.
drop_chunk() first validates the chunk status, then if it is safe to remove, it removes both the chunk
table and its entry from the chunk catalog.
You cannot drop compressed chunks directly.
Samples
Section titled “Samples”-
Drop a specific chunk by name:
SELECT _timescaledb_functions.drop_chunk('_timescaledb_internal._hyper_1_2_chunk'); -
Drop a chunk using a variable:
DO $$DECLAREchunk_name regclass;BEGINSELECT show_chunks('conditions', older_than => INTERVAL '6 months')INTO chunk_nameLIMIT 1;PERFORM _timescaledb_functions.drop_chunk(chunk_name);END $$;
Arguments
Section titled “Arguments”| Name | Type | Default | Required | Description |
|---|---|---|---|---|
chunk | REGCLASS | ✔ | The name of the chunk to drop. You can use a schema-qualified name, such as _timescaledb_internal._hyper_1_2_chunk. If the chunk is in the search path, you can use the unqualified name. |
Returns
Section titled “Returns”Returns true when the chunk is successfully dropped.