Skip to main content
For additional , use the extension.

Samples

Time bucketing with aggregates

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;

Gapfilling missing data

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;

Analyzing data distribution

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';

Approximate row counting

Get a fast estimate of table size without scanning all data:
SELECT approximate_row_count('readings');

Available function groups

Time series utilities

Core functions for time bucketing, ordered selection, and time-based calculations:

Gapfilling

Functions for filling gaps in time-series data:

Distribution analysis

Functions for analyzing data distribution patterns:

Additional hyperfunctions

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