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.
Use real-time aggregates
Section titled “Use real-time aggregates”You can enable and disable real-time aggregation by setting the
materialized_only parameter when you create or alter the view.
- Enable real-time aggregationALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = false);
- Disable real-time aggregationALTER 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.
Learn more
Section titled “Learn more”- Understand continuous aggregates: How continuous aggregates work, JOINs, and function support.
- Create a continuous aggregate: Step-by-step guide to creating a continuous aggregate with real-time aggregation.
- Refresh continuous aggregates: Control how often materialized data is updated.
- Troubleshoot continuous aggregates: Common issues and solutions.
ALTER MATERIALIZED VIEWreference: Togglematerialized_onlyand other settings.
For more information, see the troubleshooting section.