Chunks are constrained by a start and end time and the start time is always before the end time. A chunk is dropped if its end time is older than the older_than timestamp or, if newer_than is given, its start time is newer than the newer_than timestamp.

    Note that, because chunks are removed if and only if their time range falls fully before (or after) the specified timestamp, the remaining data may still contain timestamps that are before (or after) the specified one.

    Required Arguments

    Optional Arguments

    NameDescription
    newer_thanSpecification of cut-off point where any full chunks newer than this timestamp should be removed.
    verbose(BOOLEAN) Setting to true will display messages about the progress of the reorder command. Defaults to false.

    The older_than and newer_than parameters can be specified in two ways:

    • interval type: The cut-off point is computed as now() - older_than and similarly now() - newer_than. An error will be returned if an INTERVAL is supplied and the time column is not one of a TIMESTAMP, , or DATE.

    When both arguments are used, the function returns the intersection of the resulting two ranges. For example, specifying newer_than => 4 months and older_than => 3 months will drop all full chunks that are between 3 and 4 months old. Similarly, specifying newer_than => '2017-01-01' and older_than => '2017-02-01' will drop all full chunks between ‘2017-01-01’ and ‘2017-02-01’. Specifying parameters that do not result in an overlapping intersection between two ranges will result in an error.

    Sample Usage

    Drop all chunks from hypertable conditions older than 3 months:

    Example output:

    1. ----------------------------------------
    2. _timescaledb_internal._hyper_3_5_chunk
    3. _timescaledb_internal._hyper_3_6_chunk
    4. _timescaledb_internal._hyper_3_8_chunk
    5. _timescaledb_internal._hyper_3_9_chunk
    6. (5 rows)

    Drop all chunks from hypertable conditions before 2017:

    1. SELECT drop_chunks('conditions', '2017-01-01'::date);

    Drop all chunks from hypertable conditions before 2017, where time column is given in milliseconds from the UNIX epoch:

    Drop all chunks older than 3 months ago and newer than 4 months ago from hypertable conditions:

      Drop all chunks older than 3 months ago across all hypertables: