> ## Documentation Index
> Fetch the complete documentation index at: https://docs.activeviam.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How modifying the aggregates cache can speed query time

> How the Atoti aggregates cache stores previously computed measure-location pairs to avoid recalculation, including cache size configuration, caching strategies, and when to enable or avoid the cache.

The aggregates cache stores previously computed measure-location pairs.
When a query requests the same measure at the same location, the result is retrieved from the cache instead of recalculating from raw data.
This reduces query execution time significantly:

* Avoid recalculation: Cached results are returned instantly.
* Reduce datastore scans: Queries do not need to access the underlying datastore.
* Optimize repeated queries: Dashboards and reports that reuse the same measures benefit the most.

<img alt="performance-agg-cache.png" src="https://mintcdn.com/activeviam/lTzImDUNm0cHRUws/images/atoti-concepts/performance-agg-cache.png?fit=max&auto=format&n=lTzImDUNm0cHRUws&q=85&s=bfd3db2c4af813bb240700201ae83f43" width="350" data-path="images/atoti-concepts/performance-agg-cache.png" />

## How can the aggregates cache be modified?

* Enable caching: Activate the aggregates cache in the cube configuration.
* Set cache size: Define the maximum number of measure-location pairs stored.
* Choose caching strategy:
  * Cache all measures.
  * Cache only selected measures.
  * Exclude specific measures from caching.
* Clear or resize cache: Adjust cache behavior dynamically based on workload.

## When to use the aggregates cache

The aggregates cache is most effective when query patterns are predictable, and data loading is infrequent. It is less useful in real-time environments where data changes often.

### Recommended scenarios

* One-off data loading: Data is loaded once and queried repeatedly.
* Infrequent intraday updates: Cache remains valid for most queries.
* High dashboard reuse: Multiple users run similar queries.

### Avoid using the cache when

* Real-time data loading: Frequent updates clear the cache, reducing its benefit.
* Highly dynamic queries: If queries rarely repeat, caching adds little value.

## Related reading

Find out how to modify the default cache with:

* [Atoti Java SDK](/engine/java-sdk/latest/cube/configuration#configure-the-aggregate-cache)
* [Atoti Python SDK](https://docs.activeviam.com/products/atoti/python-sdk/latest/api/atoti.aggregate_cache.html#atoti-aggregatecache)
