It has been revealed that most slow MySQL queries announce themselves if you know where to look. You do not need a monitoring dashboard or a database consultant β€” you need EXPLAIN, and five signals in its output that each point at a different fix.

This is the loudest signal. MySQL read every row of the table no matter what your WHERE said. On a lookup table with 50 rows, nobody cares. On a table with 500,000 rows, this is your whole problem. The fix is almost always an index on the column in the WHERE clause. Run the query again after adding it and watch type move to ref.

According to recent reports, different from signal 1 in one notable way: sometimes possible_keys lists an index and key is still NULL. That means the index exists and MySQL refused it. The usual reason is the query itself β€” a function wrapped around the indexed column, like DATE(created_at) = '2026-11-20', or a comparison against a value of the wrong type. Rewrite the condition so the index can serve it: a date range instead of DATE(), matching types on both sides. (Related: How to generate text: using different decoding methods ...)

The index found the rows, but they came back in the wrong order, so MySQL sorted them itself β€” in memory if it fits, on disk if it does not. The cure is a composite index that covers the filter and the sort in one order: equality columns first, then the sort column. An index on (user_id, created_at) serves WHERE user_id = 1234 ORDER BY created_at DESC with no sort at all β€” MySQL reads the index backwards and stops after your LIMIT. (Related: Hugging Face Reads, Feb. 2021 - Long-range Transformers...)

Industry observers note that rows is an estimate, not a count, but the ratio tells the story. If MySQL expects to examine 498,000 rows to hand you back 20, the plan is wrong even if the query eventually finishes. Compare rows with the actual result size. A ratio in the thousands means a missing index or a condition the optimizer cannot use. When the estimate itself looks suspicious, EXPLAIN ANALYZE (MySQL 8.0.18+) runs the query and reports the real numbers.

Recent findings suggest that this one does not show up as a single bad column β€” it highlights up as a query that is fast on page 1 and slow on page 1,000. LIMIT 20 OFFSET 20000 still reads and discards 20,000 rows. The fix is keyset pagination: remember the last id you showed and ask for the next rows after it with WHERE id > 20000 ORDER BY id LIMIT 20. The index does the work, and page 1,000 costs the same as page 1.

None of these signals needs a rewrite of your application. The habit is small: when a query is slow, run EXPLAIN before you change anything, read these five signals, and make the smallest change that moves one of them. I wrote up the full walkthrough β€” finding the slow queries in the slow query log, reading every column, and verifying each fix β€” here:.

https://rajadevsolutions.online/blog/how-to-fix-slow-mysql-queries-with-explain.

Industry observers note that fix the proposal first. The query is usually innocent.

β†’ Read original article