> ## 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 后通过批量操作发起优化、批量 AI 优化或忽略，并在创建优化任务页配置基础、验证、索引与规则参数。

聚合去重后得到治理清单，下一步是对其中的慢 SQL 发起优化。慢查询页提供行级与批量两种入口，批量操作可一次对多条慢 SQL 发起优化。

## 目标

对聚合后的慢 SQL 清单发起优化，通过批量操作或行级操作进行优化、批量 AI 优化或忽略。

## 准备工作

慢 SQL 已采集并显示在慢查询页。

## 批量操作

勾选表格中的慢 SQL（可跨页多选），点击「批量操作」展开操作菜单：

<Frame caption="批量操作菜单：优化、批量 AI 优化、忽略">
  <img src="https://mintcdn.com/pawsql/cdtFYB4QMM1nGHhK/images/performance/patrol-batch-operate-menu.png?fit=max&auto=format&n=cdtFYB4QMM1nGHhK&q=85&s=b74c2baad91fffb9d688c493f20013cf" alt="批量操作菜单" width="1920" height="889" data-path="images/performance/patrol-batch-operate-menu.png" />
</Frame>

| 操作       | 说明                              |
| -------- | ------------------------------- |
| 优化       | 对选中的慢 SQL 创建优化任务，生成 SQL 重写与索引推荐 |
| 批量 AI 优化 | 对选中的慢 SQL 发起 AI 智能优化            |
| 忽略       | 将选中的慢 SQL 标记为忽略，从治理清单中排除        |

## 行级操作

每条慢 SQL 的「操作列表」列也提供三个动作：

| 按钮        | 说明                    |
| --------- | --------------------- |
| 优化        | 对单条慢 SQL 创建优化任务       |
| AI 智能优化分析 | 对单条慢 SQL 发起 AI 智能优化分析 |
| 标记忽略      | 将该 SQL 标记为忽略          |

## 创建优化任务

点击「优化」后进入「新建查询优化」页，把选中的查询打包成一条优化任务工单。优化参数的完整配置（基础、验证、索引、规则）与提交跟踪见[创建优化任务工单](/user-guide/performance/create-optimize-ticket)。

## 预期结果

选中的慢 SQL 被打包成优化任务，生成 SQL 重写与索引推荐，并在优化任务页展示。

## 验证

确认优化任务已创建，慢查询页的「优化状态」「最近优化」「性能提升」列出现优化结果。

## 常见问题

| 现象         | 优先检查             |
| ---------- | ---------------- |
| 批量操作无可选动作  | 是否已勾选慢 SQL       |
| 优化任务长时间等待  | 任务队列、并发限制、分析服务状态 |
| 性能提升显示 N/A | 是否尚未优化，或优化任务是否完成 |

## 延伸阅读

<CardGroup cols={2}>
  <Card title="SQL 聚合与去重" href="/user-guide/performance/aggregate-dedup" />

  <Card title="创建优化任务工单" href="/user-guide/performance/create-optimize-ticket" />

  <Card title="跟踪治理进度" href="/user-guide/performance/track-progress" />
</CardGroup>
