liveBook · Manning

Continuous aggregate

As explained in Just Use Postgres!

A continuous aggregate is a TimescaleDB query-result object that stores precomputed aggregate data and refreshes it incrementally according to a defined policy.

A continuous aggregate stores a precomputed query result in a hypertable and refreshes it incrementally. It suits analytical queries over large historical datasets or data queried more often than it changes. section 9.6 section 9.6.1

Detecting low heart rate

For smartwatch monitoring, aggregate measurements into five-minute buckets per watch. Store the minimum rate, readings below 50 BPM, and total measurements; then treat low_rate_count >= 5 as a detected event. Querying three consecutive buckets returns three positive results.

New measurements do not automatically update the aggregate. Define a policy with start_offset, end_offset, and schedule_interval, or refresh a precise time range manually when working with fixed historical timestamps. section 9.6.2

How Just Use Postgres! covers it

How deep it goes
Defines hypertable storage, time bucketing, querying, and refresh policies without detailed implementation internals.
Examples
Demonstrates smartwatch heart-rate buckets, low-rate detection, chunk inspection, scheduled refresh, and manual refresh.
What it assumes
Assumes a Postgres and TimescaleDB setup with time-series measurements, while demonstrating the aggregate workflow from its definition.
What you can do after
Operate/configure it by defining aggregate SQL, querying precomputed windows, and scheduling or manually invoking refreshes.
How it connects
Connects materialized views, hypertables, time buckets, refresh policies, and data retention policies.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.