Versions:
lttb() ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.ExperimentalExperimental features are not suitable for production environments. They are included under the TimescaleDB experimental schema. Click to learn more.
Toolkit
TimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale Cloud. Click to learn more.
Experimental
Experimental features are not suitable for production environments. They are included under the TimescaleDB experimental schema. Click to learn more.
Largest Triangle Three Buckets is a downsampling method that
tries to retain visual similarity between the downsampled data and the
original dataset. The TimescaleDB Toolkit implementation of this takes
(timestamp, value)
pairs, sorts them if needed, and downsamples them.
Required arguments
Name | Type | Description |
---|---|---|
time | TIMESTAMPTZ | Time (x) value for the data point |
value | DOUBLE PRECISION | Data (y) value for the data point |
resolution | INTEGER | Number of points the output should have |
Returns
Column | Type | Description |
---|---|---|
sortedtimevector | SortedTimevector | A timevector object containing the downsampled points. It can be unpacked via unnest . |
Sample usage
This example creates a dramatically downsampled data set from a sample_data
table:
SELECT time, value
FROM toolkit_experimental.unnest((
SELECT toolkit_experimental.lttb(time, val, 4)
FROM sample_data))
The output for this query:
time | value
------------------------+--------------------
2020-01-11 00:00:00+00 | 12.7015115293407
2020-02-01 00:00:00+00 | 5.004324248633603
2020-03-03 00:00:00+00 | 14.982710485116087
2020-04-20 00:00:00+00 | 10.022128489940254
Found an issue on this page?
Report an issue!