# AutoX Optimize SQL Subskill Index

Read this index after `SKILL.md` and before selecting detailed instructions.
Open only the subskills needed for the current diagnosis.

## Workflow Subskills

| Name | Use when | Path |
|---|---|---|
| input-resolution | Resolve an exact cluster or the generic all-Dedicated fleet default, SQL target, timezone, time range, diagnosis ID, and workspace before collection. | `workflow/input-resolution/SUBSKILL.md` |
| evidence-collection | Collect and summarize Slow Query, TopSQL, schema, statistics, representative executions, plan history, and build the problem profile. | `workflow/evidence-collection/SUBSKILL.md` |
| diagnosis-classification | Diagnose the bottleneck from full evidence, score root-cause classes, and generate ready-for-validation Binding, Index, TiFlash/MPP, non-optimizer, or no-action candidates. | `workflow/diagnosis-classification/SUBSKILL.md` |
| local-validation | Validate candidate plan shape in an isolated local TiDB environment using the candidates generated by diagnosis-classification. Do not invent new candidates here. | `workflow/local-validation/SUBSKILL.md` |
| final-report | Produce the action-specific customer report: plan-changing actions add `Plans Before & After`; other actions use `Conclusion` and `Analysis`. | `workflow/final-report/SUBSKILL.md` |
| batch-diagnosis | Orchestrate single-cluster or all-Dedicated fleet top-N diagnosis while preserving one focused workflow and report per `(cluster_id, digest)`. | `workflow/batch-diagnosis/SUBSKILL.md` |

## Root-Cause Class Labels

Root-cause classes are labels handled inside `workflow/diagnosis-classification/SUBSKILL.md`,
not separate subskills.

| Class | Meaning |
|---|---|
| `scan_amplification` | The plan scans or processes far more rows/keys than needed for the returned result. |
| `cardinality_error` | Wrong row estimates, pseudo or stale stats, or selectivity error materially drive the bad plan choice. |
| `wrong_access_path` | The optimizer chooses an ineffective table/index path, or no suitable access path exists for the dominant predicates/order. |
| `wrong_join_plan` | Join order, join algorithm, build/probe side, or join engine choice is the dominant issue. |
| `plan_instability` | The same digest has meaningful plan variation, regression, or parameter-sensitive instability. |
| `cop_seek_amplification` | Coprocessor requests, seeks, lookup probes, or key scans dominate latency even when the logical plan looks plausible. |
| `order_path_tradeoff` | The optimizer trades ordering against selectivity poorly, commonly around `ORDER BY`, `LIMIT`, `TopN`, or skewed early shutdown. |
| `non_optimizer_bottleneck` | Evidence points to lock, backoff, MVCC tombstones, compaction, coprocessor queueing, IO, hotspot, saturation, or another non-optimizer mechanism. |

## Loading Rules

1. Focused diagnosis: read `input-resolution`, then `evidence-collection`.
2. After `problem_profile_built`, read `diagnosis-classification`.
3. Read `local-validation` when an optimizer candidate needs plan-shape verification or when matching version, schema, and stats are available.
4. Read `final-report` only after evidence and candidate validation or blockers are recorded.
5. For top-N or batch requests, read `batch-diagnosis` first, then run the focused workflow for each selected digest.
