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

> ## Agent Instructions
> PawSQL 是一个产品：Cloud 是公网部署形态，Engine / Optimizer / Auditor / Advisor / Patroller 是同一产品的组件与交付形态，不是彼此独立的产品。 / PawSQL is a single product: Cloud is the public deployment form, while Engine / Optimizer / Auditor / Advisor / Patroller are components and delivery forms of the same product, not separate products.
> 术语以站内术语表为准：SQL 审核对应英文 SQL Review，查询重写对应 Query Rewrite，索引推荐对应 Index Recommendation；英文内容统一用 Review，不用 Audit。 / Use the site glossary for terminology: 审核 is SQL Review, 重写 is Query Rewrite, 索引推荐 is Index Recommendation; English content uses Review, never Audit.
> 引用能力范围或版本支持时以对应页面为准；标注 unknown、或 status 非 published 的内容表示尚未经产品核实，不应作为事实引用。 / Cite capability scope and version support from the corresponding page; content marked unknown, or with a status other than published, is not yet product-verified and must not be cited as fact.

# Get optimization summary

> Queries optimization summary information by optimization task ID or name.

At least one of `analysisId` and `analysisName` must be provided. If only `analysisName` is provided, it will fuzzy-match the most recent record by name.

While optimization is still in progress, only `status` and `analysisName` are returned.




## OpenAPI

````yaml /openapi/pawsql-optimization-en.yaml post /getAnalysisSummary
openapi: 3.0.3
info:
  title: PawSQL Optimization
  description: >
    PawSQL SQL optimization service external interfaces.


    The PawSQL optimization engine is a query optimization engine built for
    developers and DBAs, integrating database industry best practices for query
    optimization,

    providing powerful SQL auditing and rewrite optimization capabilities, and
    integrating the Paw Index Advisor index recommendation engine for cost-based
    index recommendations for slow queries.


    ## Authentication


    Most endpoints require authentication via `userKey` (activation code).

    The `userKey` can be obtained through the `/getUserKey` endpoint
    (email/password login).


    ## API Call Flow


    1. Call `/getUserKey` to obtain a userKey

    2. Call `/createWorkspace` to create a workspace (or pass DDL directly in
    `/createAnalysis`)

    3. Call `/createAnalysis` or `/createAnalysisAsync` to create an
    optimization task

    4. Call `/getAnalysisSummary` to obtain the optimization summary

    5. Call `/getStatementDetails` to obtain details for a single SQL statement
  version: 1.0.0
  contact:
    name: PawSQL Team
    url: https://pawsql.com
  license:
    name: PawSQL
    url: https://pawsql.com
servers:
  - url: /api/v1
    description: PawSQL Server
security:
  - userKey: []
tags:
  - name: Authentication
    description: Authentication endpoints
  - name: Workspace
    description: Workspace management endpoints
  - name: Optimization
    description: SQL optimization task endpoints
paths:
  /getAnalysisSummary:
    post:
      tags:
        - Optimization
      summary: Get optimization summary
      description: >
        Queries optimization summary information by optimization task ID or
        name.


        At least one of `analysisId` and `analysisName` must be provided. If
        only `analysisName` is provided, it will fuzzy-match the most recent
        record by name.


        While optimization is still in progress, only `status` and
        `analysisName` are returned.
      operationId: getAnalysisSummary
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ApiAnalysisRequestId'
            examples:
              byId:
                summary: Query by ID
                value:
                  userKey: CB698418-88B25371-67F15F01-XXXXXXXX
                  analysisId: '1730503067658043394'
              byName:
                summary: Query by name
                value:
                  userKey: CB698418-88B25371-67F15F01-XXXXXXXX
                  analysisName: API-ANA-20260901143022
      responses:
        '200':
          description: Optimization summary information
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ApiResult'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/AnalysisSummary'
              examples:
                completed:
                  summary: Optimization completed
                  value:
                    code: 200
                    message: Success
                    data:
                      status: success1
                      analysisName: API-ANA-20260901143022
                      basicSummary:
                        numberOfQuery: 1
                        numberOfRewrite: 2
                        numberOfIndex: 1
                        performanceImprove: 85.5
                        summaryMarkdown: ...
                      summaryStatementInfo:
                        - analysisStmtId: '1730503078953304065'
                          stmtName: Query-1
                          stmtText: select * from organization where adm_id = 100
                          costBefore: 120.5
                          costAfter: 18.3
                          performance: 84.8
                running:
                  summary: Optimization in progress
                  value:
                    code: 200
                    message: Success
                    data:
                      status: running
                      analysisName: API-ANA-20260901143022
components:
  schemas:
    ApiAnalysisRequestId:
      type: object
      description: Optimization task query request
      properties:
        userKey:
          type: string
          description: Activation code
          example: CB698418-88B25371-67F15F01-XXXXXXXX
        analysisId:
          type: string
          description: Optimization task ID
        analysisName:
          type: string
          description: >-
            Optimization task name (used when analysisId is not provided;
            fuzzy-matches the most recent record by name)
    ApiResult:
      type: object
      description: Unified response body
      properties:
        code:
          type: integer
          description: Status code, 200 indicates success
          example: 200
        message:
          type: string
          description: Description message
          example: Success
        data:
          description: Response data
    AnalysisSummary:
      type: object
      description: Optimization summary information
      properties:
        status:
          type: string
          description: 'Optimization status: success0 / success1 / failed / running'
        analysisName:
          type: string
          description: Optimization task name
        basicSummary:
          type: object
          description: Basic summary information
          properties:
            numberOfQuery:
              type: integer
              description: Number of SQL statements
            numberOfSyntaxError:
              type: integer
              description: Number of syntax errors
            numberOfRewrite:
              type: integer
              description: Number of rewrite optimizations
            numberOfRewrittenQuery:
              type: integer
              description: Number of rewritten SQL statements
            numberOfViolations:
              type: integer
              description: Number of rule violations
            numberOfViolatedQuery:
              type: integer
              description: Number of SQL statements violating rules
            numberOfIndex:
              type: integer
              description: Number of recommended indexes
            numberOfQueryIndex:
              type: integer
              description: Number of SQL statements using recommended indexes
            performanceImprove:
              type: number
              format: double
              description: Performance improvement percentage
            summaryMarkdown:
              type: string
              description: Summary Markdown report
            summaryMarkdownZh:
              type: string
              description: Chinese summary Markdown report
        summaryStatementInfo:
          type: array
          description: List of statement information
          items:
            $ref: '#/components/schemas/SummaryStatementInfo'
    SummaryStatementInfo:
      type: object
      description: Statement summary information
      properties:
        analysisStmtId:
          type: string
          description: Statement ID (used to query details)
        stmtName:
          type: string
          description: Statement name
        stmtText:
          type: string
          description: Statement SQL text
        costBefore:
          type: number
          format: double
          description: Cost before optimization
        costAfter:
          type: number
          format: double
          description: Cost after optimization
        performance:
          type: number
          format: double
          description: Statement performance improvement percentage
  securitySchemes:
    userKey:
      type: apiKey
      in: header
      name: userKey
      description: Activation code, obtained via the /getUserKey endpoint

````