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

![performance-agg-cache.png](https://mintcdn.com/activeviam/0O2WinbFW-AXLRE1/images/atoti-concepts/performance-agg-cache.png?fit=max\&auto=format\&n=0O2WinbFW-AXLRE1\&q=85\&s=7ecf0ffd3b1ca2b323d83e3e49c7fab3)

## 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](https://docs.activeviam.com/engine/java-sdk/latest/cube/configuration.md#configure-the-aggregate-cache)
* [Atoti Python SDK](https://docs.activeviam.com/engine/python-sdk/latest/api/atoti.AggregateCache)
