mysql-problem-solver

Diagnose MySQL query performance using SQL, schema, and EXPLAIN evidence.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/pekral/pekral.cz --skill mysql-problem-solver
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mysql-problem-solver
Source: https://github.com/pekral/pekral.cz/tree/main/.claude/skills/mysql-problem-solver
Command: npx skills add https://github.com/pekral/pekral.cz --skill mysql-problem-solver

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you analyze slow or inefficient MySQL queries in real applications by grounding recommendations in the actual SQL, the real schema/indexes, and EXPLAIN evidence rather than guesswork.

Core Features & Use Cases

  • Query-first investigation: Reconstructs the real SQL from provided SQL or Laravel/Eloquent/query-builder code, including filters, joins, ordering, grouping, and pagination details.
  • Schema and index verification: Reviews relevant tables and index definitions via schema output, migrations, and model relationships before suggesting any changes.
  • EXPLAIN-driven diagnosis: Interprets EXPLAIN outputs (table/type/keys/rows/filtered/Extra) to identify full scans, weak join strategies, non-SARGable predicates, poor sort/group plans, and pagination issues.
  • Safe, justified optimization proposals: Prioritizes query rewrites to reuse existing indexes (including SARGable changes and projection/index-covering considerations) and only recommends index additions when the rewrite cannot close the gap.

Quick Start

Use the mysql-problem-solver skill to analyze the slow MySQL query by providing the SQL (or the Laravel/Eloquent code that builds it), the relevant schema/migrations, and any available EXPLAIN output.

Frequently Asked Questions about mysql-problem-solver

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose slow MySQL queries using EXPLAIN output?

Diagnose slow MySQL query performance by analyzing EXPLAIN output to identify full table scans, weak join strategies, non-SARGable predicates, and poor sort or group plans. This grounds optimization recommendations in real runtime behavior rather than guesswork.

What is the best way to optimize Laravel Eloquent N+1 query problems?

Optimize Laravel Eloquent N+1 query problems by reconstructing the real SQL from query builder code, reviewing model relationships and schema definitions, and interpreting EXPLAIN evidence to identify per-row data access patterns before proposing rewrites.

How do I fix MySQL pagination queries that scan too many rows?

Fix MySQL pagination queries by interpreting EXPLAIN outputs to identify inefficient pagination plans, then applying SQL rewrites to reuse existing indexes with SARGable changes and projection considerations to reduce excessive row scanning.

Can I analyze query performance without manually checking schema indexes?

Analyzing query performance requires reviewing relevant tables and index definitions via schema output, migrations, and model relationships before suggesting changes, ensuring safe and justified optimization proposals that prioritize query rewrites over fabricated schema assumptions.

When should I add a new index versus rewriting SQL for query tuning?

Prioritize query rewrites to reuse existing indexes during SQL tuning, including SARGable changes and index-covering considerations. Only recommend adding new indexes when the query rewrite cannot close the performance gap.

Why does my MySQL join query ignore the primary key index?

MySQL join queries may ignore indexes due to non-SARGable predicates or weak join strategies identified through EXPLAIN analysis. Diagnose the exact bottleneck by examining table access types and key columns in the EXPLAIN output.