Skip to content

Hyperfunctions overview

Functions that enable you to analyze time-series data efficiently. These functions provide essential capabilities for time bucketing, data distribution analysis, and gapfilling.

For additional hyperfunctions, use the TimescaleDB Toolkit PostgreSQL extension.

Bucket temperature readings into 5-minute intervals and calculate statistics:

SELECT
time_bucket('5 minutes', time) AS bucket,
avg(temperature) AS avg_temp,
first(temperature, time) AS first_temp,
last(temperature, time) AS last_temp
FROM readings
GROUP BY bucket
ORDER BY bucket DESC;

Fill gaps in time-series data using last observation carried forward (LOCF):

SELECT
time_bucket_gapfill('1 hour', time) AS bucket,
device_id,
locf(avg(temperature)) AS filled_avg_temp
FROM readings
WHERE time >= NOW() - INTERVAL '1 day'
GROUP BY bucket, device_id
ORDER BY bucket DESC;

Create a histogram of response times to understand distribution patterns:

SELECT histogram(response_time_ms, 0, 1000, 10)
FROM api_requests
WHERE time > NOW() - INTERVAL '1 day';

Get a fast estimate of table size without scanning all data:

SELECT approximate_row_count('readings');

For advanced time-series analysis including statistical analysis, percentile approximation, state tracking, and more, see the TimescaleDB Toolkit API reference.