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

# Execution Plan Analysis

> Turn complex database execution plans into visual structures that make scans, joins, sorting, cost, and bottlenecks easier to understand.

PawSQL Execution Plan Analysis transforms native database execution plans into more intuitive graphical structures so developers and DBAs can understand SQL execution paths faster.

It is designed not only to show which operators exist, but also to help identify performance bottlenecks, explain optimization results, and compare execution plans before and after tuning.

<Note>
  This page focuses on **rendering plans and locating bottlenecks**. For **before-and-after cost validation and judgment**, see [Performance Validation](/en/features/performance-validation).
</Note>

## Overview

Database execution plans may contain many layers of operators, cost estimates, row estimates, and database-specific attributes.

For complex SQL, reading raw text plans can be difficult and time-consuming.

PawSQL converts execution plans into a normalized visual structure:

```mermaid theme={null}
flowchart LR
    A["Database EXPLAIN"] --> B["Plan Parser"] --> C["Plan Model"] --> D["Operator Analysis"] --> E["Visual Plan"]
```

## Why Execution Plan Analysis Matters

SQL performance optimization ultimately requires understanding how the database intends to execute the SQL.

SQL text alone cannot answer many important questions:

* Is the database using an index?
* Which table is being fully scanned?
* Is the join using Hash Join or Nested Loop?
* Which operator has the highest cost?
* Is Sort or Aggregate becoming a bottleneck?
* Are estimated rows expanding dramatically?
* Is a distributed database redistributing data across nodes?

Execution plans provide this information, and visualization makes complex plans easier to interpret.

## Key Capabilities

### Plan tree visualization

Display execution-plan operators and parent-child relationships as a tree or graph.

Typical operators include:

* Table Scan
* Index Scan
* Index Seek
* Nested Loop
* Hash Join
* Merge Join
* Sort
* Aggregate
* Materialize
* Exchange / Redistribute

### Cost visibility

Show key metrics at plan nodes, such as:

* Node Cost
* Total Cost
* Estimated Rows
* Actual Rows, when available
* Width / Data Volume
* Execution Time, when present in the plan

### Bottleneck identification

Help identify:

* High-cost operators
* Full table scans
* Large sorts
* Row-count explosion
* Large-table Nested Loops
* Join skew
* Distributed data movement

### Before-and-after comparison

When used with Performance Validation, PawSQL can compare:

* Original execution plans
* Plans after SQL rewrite
* Plans after index recommendation

This makes access-path changes visible rather than implicit.

## Example

Suppose the original plan is:

```text theme={null}
Nested Loop
├── Seq Scan orders
└── Index Scan customers
```

After optimization:

```text theme={null}
Hash Join
├── Index Scan orders
└── Index Scan customers
```

Visualization should help the user understand not only that operators changed, but also:

* Why the access path changed
* Which node became cheaper
* Whether scanned data volume decreased
* Whether the new index is actually being used

## Execution Plan Analysis Is Not Just a Pretty Tree

A professional execution-plan tool should do more than convert text into graphics.

The real value is helping users answer:

<Note>
  **Where is the cost? Why is it expensive? What changed after optimization?**
</Note>

PawSQL can therefore combine visualization with:

```mermaid theme={null}
flowchart TD
    V["Visualization<br>Understand the execution path quickly"]
    A["Analysis<br>Identify costly or abnormal operators"]
    C["Validation<br>Compare plan changes after optimization"]
```

## Database-aware Plan Parsing

EXPLAIN formats differ substantially across database systems.

PawSQL maps database-specific execution plans into a unified model while preserving database-specific details such as:

* MySQL access types
* PostgreSQL plan nodes
* Oracle operations
* SQL Server physical operators
* DB2 explain operators
* Distributed-database exchange / motion nodes

## Related Capabilities

<CardGroup cols={2}>
  <Card title="SQL Quality Check" icon="list-check" href="/en/features/sql-review" />

  <Card title="Query Rewrite" icon="wand-sparkles" href="/en/features/automatic-sql-rewrite" />

  <Card title="Index Recommendation" icon="layers" href="/en/features/index-recommendation" />

  <Card title="Performance Validation" icon="gauge" href="/en/features/performance-validation" />

  <Card title="Supported Databases" icon="database" href="/en/getting-started/supported-databases" />
</CardGroup>

## Related Use Cases

<CardGroup cols={2}>
  <Card title="Developer SQL Copilot" icon="code" href="/en/use-cases/developer-sql-copilot" />

  <Card title="DBA Batch Slow SQL Governance" icon="gauge" href="/en/use-cases/slow-sql-optimization" />

  <Card title="Enterprise SQL Governance Platform" icon="building-2" href="/en/use-cases/enterprise-sql-governance" />
</CardGroup>
