---
title: Hyperfunctions overview | Tiger Data Docs
description: 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](/docs/reference/toolkit/index.md) PostgreSQL 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 functions

### Time series utilities

- [`time_bucket()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/time_bucket/index.md): bucket rows by time interval
- [`first()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/first/index.md): get the first value ordered by another column
- [`last()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/last/index.md): get the last value ordered by another column
- [`days_in_month()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/days_in_month/index.md): calculate days in a month
- [`month_normalize()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/month_normalize/index.md): normalize monthly metrics

### Gapfilling

- [`time_bucket_gapfill()`](/docs/reference/timescaledb/hyperfunctions/time_bucket_gapfill/time_bucket_gapfill/index.md): bucket time and fill gaps in results
- [`locf()`](/docs/reference/timescaledb/hyperfunctions/time_bucket_gapfill/locf/index.md): last observation carried forward for filling gaps
- [`interpolate()`](/docs/reference/timescaledb/hyperfunctions/time_bucket_gapfill/interpolate/index.md): linear interpolation for filling gaps

### Distribution analysis

- [`histogram()`](/docs/reference/timescaledb/hyperfunctions/distribution-analysis/histogram/index.md): create histograms to visualize data distribution
- [`approximate_row_count()`](/docs/reference/timescaledb/hyperfunctions/distribution-analysis/approximate_row_count/index.md): fast approximate count of rows in a table

### Additional hyperfunctions

For advanced time-series analysis including statistical analysis, percentile approximation, state tracking, and more, see the [TimescaleDB Toolkit API reference](/docs/reference/toolkit/index.md).

### Deprecated hyperfunctions

- [`time_bucket_ng()`](/docs/reference/timescaledb/hyperfunctions/time-series-utilities/time_bucket/index.md): next generation time bucketing with additional features
