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

# Retrieve query execution plan by ID

> Retrieves the execution plan for a specific query by its unique identifier.

This endpoint re-executes the stored MDX query to generate the query plan data.
The query must be of type MDX, otherwise a BadArgumentException will be thrown.
An optional timeout can be specified to limit the execution time of the query plan generation.

Note: This operation requires an active cube setup and will re-execute the query.




## OpenAPI

````yaml get /activeviam/query-history/rest/v1/query/{id}/query-plan
openapi: 3.1.0
info:
  title: Atoti REST services
  version: 6.1.19-SNAPSHOT
servers:
  - description: Generated server url
    url: http://localhost:9090
security: []
tags:
  - description: Implementation of the REST API controller for an ActivePivot database.
    name: Database REST API
  - description: >
      XML for Analysis (XMLA) endpoint for executing MDX queries and OLAP
      discovery operations.


      This endpoint implements the XMLA protocol which is used by:

      - Microsoft Excel and other OLAP clients

      - Custom BI tools that support XMLA connectivity


      The endpoint supports both text XML and binary XML formats for improved
      performance.
    name: XMLA API
  - description: Definition of REST API to query data from ActivePivot (V10).
    name: Query REST API (V10)
  - description: Definition of REST API to query data from ActivePivot (V9).
    name: Query REST API (V9)
  - description: Implementation of the REST Bulk API of the content server (version 8).
    name: Bulk REST API
  - description: Implementation of the REST API of the content server.
    name: Content Server REST API
  - description: Implementation of the REST API controller for an ActivePivot database.
    name: Database REST API v9
  - description: ' Definition of the REST service returning the list of services exposed by an application.'
    name: Version REST API
  - description: Rest Service providing the discovery information.
    name: Discovery REST API
  - description: JSON Web Token (JWT) endpoint.
    name: JWT API
  - description: >
      Endpoints to retrieve and manage query history.


      **Note:** This API is experimental and may change in future versions
      without notice.
    name: Query History REST API (Experimental)
  - description: Description of REST API to configure an ActivePivot application.
    name: Configuration REST API
  - description: API to export the result of MDX queries
    name: Data Export
  - description: >
      GetAggregatesQuery (GAQ) REST API for executing OLAP queries.


      This API provides a programmatic way to execute GetAggregatesQuery
      operations

      against Atoti cubes. Results and updates are streamed in Apache Arrow
      format for efficient

      data transfer and processing.
    name: Continuous GAQ Query REST API (Experimental)
  - description: Endpoints for AI-based optimization of Atoti cubes
    name: AI Optimizer
  - description: >
      GetAggregatesQuery (GAQ) REST API for executing OLAP queries.


      This API provides a programmatic way to execute GetAggregatesQuery
      operations

      against Atoti cubes. Results are returned in Apache Arrow format for
      efficient

      data transfer and processing.


      **Note:** This API is experimental and may change in future versions
      without notice.
    name: GAQ Query REST API (Experimental)
  - description: Implementation of the REST Bulk API of the content server.
    name: Bulk REST API
paths:
  /activeviam/query-history/rest/v1/query/{id}/query-plan:
    get:
      tags:
        - Query History REST API (Experimental)
      summary: Retrieve query execution plan by ID
      description: >
        Retrieves the execution plan for a specific query by its unique
        identifier.


        This endpoint re-executes the stored MDX query to generate the query
        plan data.

        The query must be of type MDX, otherwise a BadArgumentException will be
        thrown.

        An optional timeout can be specified to limit the execution time of the
        query plan generation.


        Note: This operation requires an active cube setup and will re-execute
        the query.
      operationId: getQueryPlanById
      parameters:
        - description: Unique identifier of the query history entry
          example: 12345
          in: path
          name: id
          required: true
          schema:
            type: string
        - description: >-
            Optional timeout for query plan generation in ISO-8601 duration
            format (e.g., PT30S for 30 seconds)
          example: PT30S
          in: query
          name: timeout
          required: false
          schema:
            type: string
      responses:
        '200':
          content:
            '*/*':
              schema:
                items:
                  $ref: '#/components/schemas/JsonQueryPlanData'
                type: array
          description: Query execution plan retrieved successfully
        '400':
          content:
            '*/*':
              schema:
                items:
                  $ref: '#/components/schemas/JsonQueryPlanData'
                type: array
          description: Bad request - query type must be MDX or invalid timeout format
        '404':
          content:
            '*/*':
              schema:
                items:
                  $ref: '#/components/schemas/JsonQueryPlanData'
                type: array
          description: Query not found - no entry exists with the specified ID
        '500':
          content:
            '*/*':
              schema:
                items:
                  $ref: '#/components/schemas/JsonQueryPlanData'
                type: array
          description: Internal server error - no cube setup or query execution failed
components:
  schemas:
    JsonQueryPlanData:
      properties:
        aggregateRetrievals:
          items:
            $ref: '#/components/schemas/RetrievalData'
          type: array
        databaseDependencies:
          additionalProperties:
            items:
              format: int32
              type: integer
            type: array
            uniqueItems: true
          type: object
        databaseRetrievals:
          items:
            $ref: '#/components/schemas/DatabaseRetrievalData'
          type: array
        dependencies:
          additionalProperties:
            items:
              format: int32
              type: integer
            type: array
            uniqueItems: true
          type: object
        planInfo:
          $ref: '#/components/schemas/IPlanInfoData'
        queryFilters:
          items:
            $ref: '#/components/schemas/FilterData'
          type: array
        querySummary:
          $ref: '#/components/schemas/QuerySummaryData'
      type: object
    RetrievalData:
      properties:
        filterId:
          format: int32
          type: integer
        horizontalDispatching:
          $ref: '#/components/schemas/QueryDispatchingData'
        location:
          items:
            $ref: '#/components/schemas/LocationData'
          type: array
        measureProvider:
          type: string
        measures:
          items:
            type: string
          type: array
        partialProviderName:
          type: string
        partitioning:
          type: string
        resultSizes:
          items:
            format: int32
            type: integer
          type: array
        retrievalId:
          format: int32
          type: integer
        timingInfo:
          additionalProperties:
            items:
              format: int64
              type: integer
            type: array
          type: object
        type:
          type: string
        underlyingDataNodes:
          items:
            type: string
          type: array
      type: object
    DatabaseRetrievalData:
      properties:
        condition:
          type: string
        fields:
          items:
            type: string
          type: array
          uniqueItems: true
        joinedMeasure:
          items:
            type: string
          type: array
          uniqueItems: true
        resultSizes:
          items:
            format: int32
            type: integer
          type: array
        retrievalId:
          format: int32
          type: integer
        store:
          type: string
        timingInfo:
          additionalProperties:
            items:
              format: int64
              type: integer
            type: array
          type: object
      type: object
    IPlanInfoData:
      type: object
    FilterData:
      properties:
        description:
          type: string
        id:
          format: int32
          type: integer
      type: object
    QuerySummaryData:
      properties:
        measures:
          items:
            type: string
          type: array
          uniqueItems: true
        partialProviders:
          items:
            type: string
          type: array
          uniqueItems: true
        partitioningCountByType:
          additionalProperties:
            format: int32
            type: integer
          type: object
        resultSizeByPartitioning:
          additionalProperties:
            format: int32
            type: integer
          type: object
        retrievalsCountByType:
          additionalProperties:
            format: int32
            type: integer
          type: object
        totalDatabaseResultSize:
          format: int32
          type: integer
        totalRetrievals:
          format: int32
          type: integer
      type: object
    QueryDispatchingData:
      properties:
        dispatchingPerApplication:
          items:
            $ref: '#/components/schemas/ApplicationDispatchingData'
          type: array
      type: object
    LocationData:
      properties:
        dimension:
          type: string
        hierarchy:
          type: string
        level:
          items:
            type: string
          type: array
        path:
          items:
            type: object
          type: array
      type: object
    ApplicationDispatchingData:
      properties:
        applicationName:
          type: string
        dispatchingPerLevel:
          additionalProperties:
            additionalProperties:
              $ref: '#/components/schemas/CubeDispatchingData'
            type: object
          type: object
      type: object
    CubeDispatchingData:
      properties:
        dispatchedMembers:
          additionalProperties:
            items:
              type: object
            type: array
          type: object
      type: object

````