> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify-poc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Set up real-time aggregates

> Combine pre-aggregated data with the most recent raw data for up-to-date results

export const TIME_BUCKET = 'time bucket';

export const CAGG = 'continuous aggregate';

export const HYPERTABLE = 'hypertable';

export const HYPERCORE = 'hypercore';

export const PG = 'Postgres';

export const COLUMNSTORE = 'columnstore';

export const TIMESCALE_DB = 'TimescaleDB';

Rapidly growing data means you need more control over what to aggregate and how to aggregate it. With this
in mind, Timescale equips you with tools for more fine-tuned data analysis.

By default, {CAGG}s 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 {TIMESCALE_DB} 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 {CAGG}, queries to that view include the
results from the most recent raw data.

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

## 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.

1. **Enable real-time aggregation for an existing {CAGG}**

   ```sql theme={"dark"}
   ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = false);
   ```

2. **Disable real-time aggregation**

   Disable real-time aggregation:

   ```sql theme={"dark"}
   ALTER MATERIALIZED VIEW table_name set (timescaledb.materialized_only = true);
   ```

## Real-time aggregates and refreshing historical data

Real-time aggregates combine materialized data with real-time calculations on recent data. However,
if you update, insert, or delete data in a previously materialized time bucket, those changes are
not visible in your {CAGG} until you refresh that time bucket again.

For more information and a detailed example, see the troubleshooting guide:
[Updates to previously materialized regions aren't shown in real-time aggregates][troubleshoot-rtagg-updates].

[troubleshoot-rtagg-updates]: /manage-data/troubleshooting/troubleshooting#updates-to-previously-materialized-regions-aren't-shown-in-real-time-aggregates

[blog-rtaggs]: https://tigerdata.com/blog/achieving-the-best-of-both-worlds-ensuring-up-to-date-results-with-real-time-aggregation/
