> ## 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 the query plan can help troubleshoot slow queries

> How the Atoti query plan records execution steps, dependencies, timing, result sizes, and retrieval methods for each query, and how to use the Atoti Query Analyser to diagnose slow queries.

The query plan provides detailed information about how Atoti executes a query.
It shows the steps taken, their dependencies, and the time required for each step.
This helps identify bottlenecks and optimize query performance.

<img alt="performance-query-plan.png" src="https://mintcdn.com/activeviam/lTzImDUNm0cHRUws/images/atoti-concepts/performance-query-plan.png?fit=max&auto=format&n=lTzImDUNm0cHRUws&q=85&s=936b580136a437c1c440f84fd054c3eb" width="300" data-path="images/atoti-concepts/performance-query-plan.png" />

## Why use the query plan

* Diagnose slow queries: Understand which steps take the longest.
* Identify dependencies: See how measures depend on each other.
* Optimize partitioning: Check if the partitioning strategy is effective.
* Detect issues: Spot cyclical measure definitions or excessive result sizes.

## What information does the query plan provide

* **Dependencies:** Shows the calculation order for measures.
* **Execution times:**
  * **Start time:** When a step begins.
  * **Elapsed time:** How long the step takes.
* **Result size:** Number of points retrieved at each step.
* **Partitioning strategy:** Indicates constant, value, or modulo partitioning.
* **Retrieval method:** Whether data comes from cache, datastore, or post-processor.

## How to analyze the query plan

* Look for long steps: High elapsed time indicates a bottleneck.
* Check result size: Large result sets may explain slow performance.
* Review partitioning: Ensure partitioning matches datastore configuration.
* Identify retrieval type:
  * Cache retrieval = fast.
  * Primitive retrieval = datastore scan (slower).
  * Post-processor retrieval = additional computation.

Use the [Atoti Query Analyser](https://activeviam.github.io/atoti-query-analyser/) to:

* Upload query plan output.
* Visualize dependencies and timing.
* Spot problematic steps quickly.
* Check when an aggregate provider is used.
* Understand how a query is distributed in a horizontal setup.

## When to use the query plan

The query plan is most useful when:

* Dashboards or widgets load slowly.
* Queries return fewer results than expected.
* You suspect inefficient partitioning or retrieval methods.

## Related reading

* [Query plan for Atoti Java SDK and Atoti Python SDK](/engine/java-sdk/latest/monitoring/query_execution_plan)
