You run EXPLAIN on a slow query, see type: ALL and rows: 1200000, and think: "No index — add one." Then you add it, the query gets faster, and two weeks later inserts start timing out. This is the most common way an index fix backfires. The problem isn't the index — it's the guesswork.
This roundup compares two ways to read a slow query plan: manual EXPLAIN reading and structured LLM prompts. We'll give you the prompts, the trade-offs, and a clear rule for when each approach pays off.
The real reason EXPLAIN lies to you
EXPLAIN estimates. It doesn't run the query. The rows column is a guess based on statistics that may be stale. A plan showing rows: 100 can actually scan a million rows if the optimizer's estimate is off. More on the topic: “Your Index Guess Is a Coin Flip: Prompts That Make an LLM Read EXPLAIN ANALYZE and Name the Bottleneck First”.
Here's what a typical bad plan looks like:
EXPLAIN SELECT o.id, c.name
FROM orders o
JOIN customers c ON c.id = o.customer_id
WHERE o.status = 'pending'
AND o.created_at > '2026-01-01';
Output:
| id | select_type | table | type | possible_keys | key | rows | Extra |
|---|---|---|---|---|---|---|---|
| 1 | SIMPLE | o | ALL | NULL | NULL | 1200000 | Using where |
| 1 | SIMPLE | c | eq_ref | PRIMARY | PRIMARY | 1 | NULL |
The plan says "full scan on orders." The instinct is to add an index on status and created_at. But which order? A composite index (status, created_at) behaves very differently from (created_at, status). And if status has only three values, the index may not be used at all — the optimizer will still choose a full scan.
Manual reading gives you the raw facts. It doesn't tell you why the optimizer chose this plan or what will happen if you change the index. That's where structured LLM prompts come in. More on the topic: “Twelve Prompts That Read EXPLAIN ANALYZE Better Than You Do — and the Three Moments When You Should Not Trust Them”.
When manual EXPLAIN is enough (and faster)
If the plan has one table, no subqueries, and the bottleneck is obvious — a missing index on a WHERE column with high selectivity — just add the index. No LLM needed. You'll spend 30 seconds.
Example: SELECT * FROM users WHERE email = 'x@y.com' with type: ALL. Add an index on email. Done.
Manual reading fails when:
- The plan has multiple JOINs and temporary tables.
- You need to test a hypothesis about an index without running
ALTER TABLEon production. - The optimizer's row estimates are clearly wrong, and you need to know why.
Prompt 1: The "explain the plan" prompt
Use this when you have a complex plan and need a plain-English breakdown of what MySQL is actually doing. Paste the full EXPLAIN output and the query.
Prompt:
You are a MySQL performance engineer. I will give you a query and its EXPLAIN output. Your job is to explain, step by step, what the optimizer is doing and where the time goes. Do not suggest fixes yet — just diagnose.
Query: [paste query]
EXPLAIN output: [paste table]
Table sizes: [approx row counts]
Existing indexes: [list]
Answer:
1. What is the access path for each table (full scan, index scan, index lookup)?
2. Which step is likely the bottleneck and why?
3. Are the row estimates plausible given the table sizes? If not, what statistics might be stale?
4. Is there a temporary table or filesort? What causes it?
Usage example: you have a 3-table JOIN with Using temporary; Using filesort in the Extra column. The LLM will tell you which ORDER BY or GROUP BY triggers the temp table and whether an index can eliminate it.
Prompt 2: The "index hypothesis" prompt
This is the one that saves you from breaking production. Before you run ALTER TABLE, ask the LLM to predict the plan with a hypothetical index.
Prompt:
I am considering adding an index to a MySQL table. Before I run ALTER TABLE, I need you to predict the new EXPLAIN plan and flag risks.
Current query: [paste query]
Current EXPLAIN: [paste]
Proposed index: CREATE INDEX idx_name ON table (col1, col2);
Table: ~[N] rows, [write rate] inserts/updates per day.
Answer:
1. Will MySQL use this index for this query? Why or why not?
2. What is the estimated rows reduction?
3. What is the write overhead (insert/update cost) of this index?
4. Is there a covering index alternative that avoids table lookups?
5. What could go wrong in production?
Usage example: you want to add (status, created_at) to a 5M-row orders table. The LLM might warn that status has low cardinality, so MySQL may ignore the index — and suggest (created_at, status) instead, which can be used for range scans.
Prompt 3: The "don't break the index" checklist
Before any schema change, run this prompt to catch the classic mistakes.
Prompt:
Review this index change for MySQL 8.0 production safety. Flag any of these issues:
- Index on a low-cardinality column that won't be used.
- Missing composite index order (equality columns first, then range).
- Redundant index (prefix of an existing index).
- Foreign key index missing.
- Online DDL limitations (locking, replication lag).
Change: [paste ALTER TABLE statement]
Table size: [rows]
Existing indexes: [list]
Output: a bullet list of risks with severity (high/medium/low) and a recommended safer alternative.
Usage example: you're about to add an index on (user_id) but there's already a composite index on (user_id, created_at). The LLM flags it as redundant — the composite index already covers user_id queries.
The decision rule
Use this table to choose your approach:
| Situation | Manual EXPLAIN | LLM prompt |
|---|---|---|
| Single-table query, missing index on high-cardinality column | ✅ 30 seconds | Overkill |
| Multi-JOIN with temp tables and filesort | Slow, error-prone | ✅ Prompt 1 |
| Testing an index hypothesis before ALTER TABLE | Can't predict | ✅ Prompt 2 |
| Checking for redundant or low-cardinality indexes | Easy to miss | ✅ Prompt 3 |
| Plan looks fine but query is still slow | Need to check statistics | ✅ Prompt 1 |
Rule of thumb: if you can't explain the plan to a colleague in one sentence, use an LLM prompt. If you can, manual reading is faster.
A real example: the case of the missing index
A team had a slow query on a logs table with 10M rows. EXPLAIN showed type: ALL. They added an index on created_at. The query got faster — but inserts slowed down by 40% because every insert now updated the index. They didn't need the index for inserts, but the write overhead was real.
The LLM prompt would have asked: "What is the write overhead?" and flagged that a partial index or a different column order might be better. Manual reading missed that because the plan looked fine after the index.
What to do next
Pick one slow query from your production slow_query_log. Run EXPLAIN on it. If the plan has more than two tables or a temp table, paste it into Prompt 1. If you're about to add an index, run Prompt 2 first. Then compare the LLM's prediction with what actually happens in a staging environment.
The goal isn't to replace your DBA — it's to stop guessing before you touch production. More on the topic: “Stop Guessing at Indexes: Prompts That Make an LLM Read EXPLAIN ANALYZE Like a DBA”.