Real time aggregates
Continuous aggregates do not include the most recent data chunk from the underlying hypertable. Real time aggregates use the aggregated data and add the most recent raw data to it to provide accurate and up to date results, without needing to aggregate data as it is being written. In TimescaleDB 1.7 and later, real time aggregates are enabled by default. When you create a continuous aggregate view, queries to that view include the most recent data, even if it has not yet been aggregated.
For more detail on the comparison between continuous and real time aggregates, see our real time aggregate blog post.
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.
Using real time aggregation
For an existing table, at the
psql
prompt, disable real time aggregation:ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = true);
Re-enable real time aggregation:
ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = false);
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.