Skip to content

Real-time aggregates

Real-time aggregates combine pre-aggregated data with the most recent raw data for up-to-date results

High-ingest workloads need aggregates that blend historical rollups with the live tail without blocking writers.

By default, continuous aggregates do not include the most recent data chunk from the underlying hypertable. Real-time aggregates, however, use the aggregated data and add the most recent raw data to it. This provides accurate and up-to-date results, without needing to aggregate data as it is being written.

In TimescaleDB v2.13 and later, real-time aggregates are DISABLED by default. In earlier versions, real-time aggregates are ENABLED by default; when you create a continuous aggregate, queries to that view include the results from the most recent raw data.

For more detail on the comparison between continuous aggregates and real-time aggregates, see the real-time aggregate blog post.

You can enable and disable real-time aggregation by setting the materialized_only parameter when you create or alter the view.

  1. Enable real-time aggregation
    ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = false);
  2. Disable real-time aggregation
    ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = true);

Real-time aggregates and refreshing historical data

Section titled “Real-time aggregates and refreshing historical data”

Real-time aggregates automatically add the most recent data when you query your continuous aggregate. In other words, they include data more recent than your last materialized bucket.

If you add new historical data to an already-materialized bucket, it won’t be reflected in a real-time aggregate. You should wait for the next scheduled refresh, or manually refresh by calling refresh_continuous_aggregate. You can think of real-time aggregates as being eventually consistent for historical data.

For more information, see the troubleshooting section.