> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# num_live_ranges()

> Count the number of live ranges

<Icon icon="tag" iconType="duotone" /> Since [1.16.0][toolkit-1.16.0]

Return the number of live periods from a heartbeat aggregate.

## Samples

Given a table called `liveness` containing weekly heartbeat aggregates in column `health` with timestamp column `date`,
use this query to see how many intervals the system was up in a given week:

```sql theme={"dark"}
SELECT num_live_ranges(health)
FROM liveness
WHERE date = '01-9-2022 UTC'
```

Returns:

```
 num_live_ranges
---------
 5
```

## Arguments

The syntax is:

```sql theme={"dark"}
num_live_ranges(
    agg HEARTBEATAGG
) RETURNS BIGINT
```

| Name | Type         | Default | Required | Description                                            |
| ---- | ------------ | ------- | -------- | ------------------------------------------------------ |
| agg  | HeartbeatAgg | -       | ✔        | A heartbeat aggregate to get the number of ranges from |

## Returns

| Column            | Type   | Description                                 |
| ----------------- | ------ | ------------------------------------------- |
| num\_live\_ranges | bigint | The number of live ranges in the aggregate. |

[toolkit-1.16.0]: https://github.com/timescale/timescaledb-toolkit/releases/tag/1.16.0
