tidb-query-tuning

Installation
SKILL.md

TiDB Query Tuning

Use this skill to diagnose and resolve TiDB query performance issues. It follows a rigorous workflow from symptom identification to verified solution.


Workflow

  1. Capture the current plan & clues:
    • Run EXPLAIN ANALYZE <query> to get actual execution stats.
    • Compare estRows vs actRows — large divergence means stale or missing statistics.
    • Note the most expensive operators (wall time, memory, rows processed).
    • Use PLAN REPLAYER: Run PLAN REPLAYER DUMP EXPLAIN [ANALYZE] <query>; to export comprehensive on-site information (version, config, stats, plan) to a ZIP file.
    • Use Debug API: Use TiDB HTTP API (port 10080) to pull runtime info: /debug/pprof, /stats/dump/{db}/{table}, or /schema/{db}/{table}.
    • Check Bindings: Run SHOW GLOBAL BINDINGS; to see if existing plan baselines are affecting the query.
Related skills

More from pingcap/agent-rules

Installs
5
GitHub Stars
24
First Seen
Mar 18, 2026