Samples
Given a table calledliveness containing weekly heartbeat aggregates in column health with timestamp column date,
use this query to roll up several weeks and trim the result to an exact month:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Reduce the covered interval of a heartbeat aggregate
liveness containing weekly heartbeat aggregates in column health with timestamp column date,
use this query to roll up several weeks and trim the result to an exact month:
SELECT trim_to(rollup(health), '03-1-2022 UTC', '1 month')
FROM liveness
WHERE date > '02-21-2022 UTC' AND date < '3-7-2022 UTC'
trim_to(
agg HEARTBEATAGG,
start TIMESTAMPTZ,
duration INTERVAL
) RETURNS HEARTBEATAGG
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| agg | HeartbeatAgg | - | ✔ | A heartbeat aggregate to trim down |
| start | TimestampTz | - | The start of the trimmed range. If not provided, the returned heartbeat aggregate starts from the same time as the starting one | |
| duration | Interval | - | How long the resulting aggregate should cover. If not provided, the returned heartbeat aggregate ends at the same time as the starting one |
| Column | Type | Description |
|---|---|---|
| trim_to | heartbeat_agg | The trimmed aggregate. |