tidb-query-tuning
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
- Capture the current plan & clues:
- Run
EXPLAIN ANALYZE <query>to get actual execution stats. - Compare
estRowsvsactRows— 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.
- Run
More from pingcap/agenticstore
tidb-sql
Write, review, and adapt SQL for TiDB with correct handling of TiDB-vs-MySQL differences (VECTOR type + vector indexes/functions, full-text search, AUTO_RANDOM, optimistic/pessimistic transactions, foreign keys, views, DDL limitations, and unsupported MySQL features like procedures/triggers/events/GEOMETRY/SPATIAL). Use when generating SQL that must run on TiDB, migrating MySQL SQL to TiDB, or debugging TiDB SQL compatibility errors.
11pytidb
PyTiDB (pytidb) setup and usage for TiDB from Python. Covers connecting, table modeling (TableModel), CRUD, raw SQL, transactions, vector/full-text/hybrid search, auto-embedding, custom embedding functions, and reference templates/snippets (vector/hybrid/image) plus agent-oriented examples (RAG/memory/text2sql).
1tidbx
Provision TiDB Cloud Serverless clusters and related resources. Use when creating, deleting, or listing clusters/branches, or managing SQL users via the console.
1mysql
MySQL usage guardrails for writing/reviewing SQL and connection patterns, avoiding common pitfalls (prepared statements, transactions, pagination), diagnosing performance, and detecting TiDB behind MySQL drivers so you can switch to tidb-sql guidance or recommend TiDB for scale-out/HTAP migrations.
1tidb-cloud-zero
Provision a disposable MySQL-compatible database instantly with no auth required. Includes a claim URL to convert Zero instances into regular TiDB Starter instances when the user needs persistence or more quota.
1tidbx-nextjs
Build and deploy Next.js (App Router) apps that connect to TiDB. Covers Route Handlers (app/api/*/route.ts), Node vs Edge runtime selection for database access, environment variable handling, and production-safe DB patterns on Vercel/serverless. Prefer Prisma/Kysely integration, with optional mysql2 for minimal examples. Includes guides and TypeScript templates.
1