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

# SQL Optimization Overview

> Create a workload and submit SQL, configure an optimization task, read summary and detail results, and validate and apply rewrite and index suggestions.

PawSQL integrates query-optimization best practices to help developers and DBAs solve SQL performance problems through query rewrite and intelligent index recommendation, and records optimization history for review, tracking, and sharing.

## Prerequisites

A workspace whose tables, views, indexes, and statistics match the environment you optimize against.

## Concepts in PawSQL

* **Workspace**: the environment (tables, views, indexes, and related statistics) you optimize against.
* **Workload**: a single DML statement or a set of DML statements you want to optimize and analyze.
* **Optimization**: an operation PawSQL performs against a workspace to optimize a workload, typically including SQL audit, rewrite, and index recommendation.

## Four steps to optimize

<Steps>
  <Step title="Create a workspace">
    Build a workspace from a database connection, an uploaded DDL file, or manual DDL input so tables, indexes, and statistics match the real environment.
  </Step>

  <Step title="Input SQL to optimize">
    Provide SQL from a text box, a SQL file, database logs, or a MyBatis Mapper file.
  </Step>

  <Step title="Create an optimization task">
    Configure basic options, validation, index recommendation, and rule settings, then submit.
  </Step>

  <Step title="Read the results">
    Drill from the summary into per-SQL details to review rewrite, audit, index, and validation results and compare execution plans.
  </Step>
</Steps>

## Pages in this section

<CardGroup cols={2}>
  <Card title="Input SQL to optimize" href="/en/user-guide/optimization/create-workload" />

  <Card title="Create and configure an optimization task" href="/en/user-guide/optimization/setup-optimization" />

  <Card title="Read the results" href="/en/user-guide/optimization/explain-output" />

  <Card title="Evaluate and apply suggestions" href="/en/user-guide/optimization/apply-suggestions" />
</CardGroup>

## Choose an entry point

| Entry point   | Best suited for                     | Strength                                            |
| ------------- | ----------------------------------- | --------------------------------------------------- |
| Web console   | Ad hoc or complex analysis          | Full result inspection and export                   |
| IDE extension | Development-time feedback           | Analysis without leaving the editor                 |
| PawSQL MCP    | AI-assisted coding workflows        | Structured tool invocation with development context |
| API           | Automation and platform integration | Repeatable, orchestrated execution                  |

## Expected Result

A completed optimization task with SQL audit, rewrite, and index recommendation results that you can review, track, and share.

## Verification

Work through the four steps—create a workspace, input SQL, create a task, and read the results—and confirm the summary and per-SQL details are complete.

## Next steps

* Configure analysis context in [Workspaces & Context](/en/user-guide/workspaces).
* Review the capabilities behind [Query Rewrite](/en/features/automatic-sql-rewrite) and [Index Recommendation](/en/features/index-recommendation).
