show_chunks function.
s are constrained by a start and end time and the start time is
always before the end time. A 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 s 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.
s can only be dropped based on their time intervals. They cannot be dropped
based on a hash partition.
Samples
-
Drop all s from
conditionsolder than 3 months:Example output: -
Drop all s from
conditionscreated before 3 months: -
Drop all s more than 3 months in the future from
conditions: This is useful for correcting data ingested with incorrect clocks: -
Drop all s from
conditionsbefore 2017: -
Drop all s from
conditionsbefore 2017, where time column is given in milliseconds from the UNIX epoch: -
Drop all s older than 3 months ago and newer than 4 months ago from
conditions: -
Drop all s created 3 months ago and created 4 months before from
conditions: -
Drop all s older than 3 months ago across all s:
Arguments
The syntax is:
The
older_than and newer_than parameters can be specified in two ways:
-
interval type: The cut-off point is computed as
now() - older_thanand similarlynow() - newer_than. An error is returned if an INTERVAL is supplied and the time column is not one of aTIMESTAMP,TIMESTAMPTZ, orDATE. -
timestamp, date, or integer type: The cut-off point is
explicitly given as a
TIMESTAMP/TIMESTAMPTZ/DATEor as aSMALLINT/INT/BIGINT. The choice of timestamp or integer must follow the type of the ‘s time column.
created_before and created_after parameters can be specified in two ways:
-
interval type: The cut-off point is computed as
now() - created_beforeand similarlynow() - created_after. This uses the creation time relative to the current time for the filtering. -
timestamp, date, or integer type: The cut-off point is
explicitly given as a
TIMESTAMP/TIMESTAMPTZ/DATEor as aSMALLINT/INT/BIGINT. The choice of integer value must follow the type of the ‘s partitioning column. Otherwise the creation time is used for the filtering.
older_than and newer_than 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 drops all s between 3 and 4 months old.
Similarly, specifying newer_than => '2017-01-01' and older_than => '2017-02-01' drops all s between ‘2017-01-01’ and
‘2017-02-01’. Specifying parameters that do not result in an
overlapping intersection between two ranges results in an error.
When both created_before and created_after arguments are used, the
function returns the intersection of the resulting two ranges. For
example, specifying created_after => 4 monthsandcreated_before=> 3 months drops all s created between 3 and 4 months from now.
Similarly, specifying created_after=> ‘2017-01-01’andcreated_before => '2017-02-01' drops all s created between ‘2017-01-01’ and
‘2017-02-01’. Specifying parameters that do not result in an
overlapping intersection between two ranges results in an error.
The
created_before/created_after parameters cannot be used together with
older_than/newer_than.Returns
The function returns a set of names in the format
_timescaledb_internal._hyper_X_Y_chunk, where each row represents a that was successfully dropped. If no s match the specified criteria, the function returns an empty result set.