mysql-query-performance/SKILL.md
Expert MySQL 8 query performance tuning: EXPLAIN analysis, index design, optimizer hints, slow query diagnosis, and profiling. Use when optimizing slow queries, designing indexes, analyzing EXPLAIN output, or diagnosing MySQL performance problems.
npx skillsauth add peterbamuhigire/skills-web-dev mysql-query-performanceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
mysql-query-performance or would be better handled by a more specific companion skill.SKILL.md first, then load only the referenced deep-dive files that are necessary for the task.Sources: MySQL 8 Query Performance Tuning (Krogh, Apress 2020) + Efficient MySQL Performance (Nichter, O'Reilly 2022)
EXPLAIN ANALYZE (MySQL 8.0.18+) executes the query and returns actual measured statistics alongside estimates. This is the single most important diagnostic upgrade over plain EXPLAIN.
-- Standard EXPLAIN: estimates only, query NOT executed
EXPLAIN FORMAT=JSON SELECT * FROM orders WHERE customer_id = 42;
-- EXPLAIN ANALYZE: executes query, returns actual vs estimated
EXPLAIN ANALYZE SELECT * FROM orders WHERE customer_id = 42;
Reading EXPLAIN ANALYZE output — key fields:
-> Index lookup on orders using idx_customer (customer_id=42)
(cost=18.50 rows=41)
(actual time=0.134..2.847 rows=38 loops=1)
cost=18.50 rows=41 — optimizer's estimate before executionactual time=0.134..2.847 — real elapsed ms (first row .. last row)rows=38 loops=1 — actual rows returned, loop count for nested joinsrows (estimated) diverges greatly from actual rows, index statistics are stale or a histogram is neededloops=N on an inner table means the entire sub-operation ran N times — multiply actual time by loops for total costEXPLAIN FORMAT=JSON shows the cost model breakdown without executing:
EXPLAIN FORMAT=JSON SELECT o.id, c.name
FROM orders o JOIN customers c ON o.customer_id = c.id
WHERE o.status = 'pending'\G
Look for "cost_info" → "read_cost" + "eval_cost" to understand why the optimizer chose a plan. The "chosen" boolean inside "considered_execution_plans" reveals rejected alternatives.
EXPLAIN FOR CONNECTION — get the live plan of a running query without re-running it (critical when index stats may have changed): EXPLAIN FOR CONNECTION 42;
Extended guidance for mysql-query-performance was moved to references/skill-deep-dive.md to keep this entrypoint compact and fast to load.
Use that deep dive for:
2. Index Selection — Why MySQL Ignores Your Index3. Covering Index Strategy and ICP4. Index Merge — Usually a Warning Sign5. Invisible Index Trick6. Histogram Statistics7. Optimizer Hints (MySQL 8.0)8. Derived Table Materialization9. Slow Query Log Analysis10. Essential Performance Schema Queries11. InnoDB Buffer Pool12. Sort Optimisation (filesort vs Index Sort)13. JOIN Algorithmsdata-ai
Use when adding AI-powered analytics to a SaaS platform — semantic search over business data, natural language queries, trend detection, anomaly alerts, and AI-generated insights for dashboards. Covers embeddings, NL2SQL, and per-tenant analytics...
data-ai
Design AI-powered analytics dashboards — what metrics to show, how to display AI predictions and confidence, drill-down patterns, KPI cards, trend visualisation, AI Insights panels, export design, and role-based dashboard variants. Invoke when...
development
Use when designing, building, reviewing, or upgrading production software systems that must be secure, performant, maintainable, scalable, and user-centered. Apply before writing specs, code, architecture, APIs, databases, mobile apps, SaaS platforms, or ERP systems.
development
Professional web app UI using commercial templates (Tabler/Bootstrap 5) with strong frontend design direction when needed. Use for CRUD interfaces, dashboards, admin panels with SweetAlert2, DataTables, Flatpickr. Clone seeder-page.php, use...