Query Execution Plans
Use EXPLAIN or EXPLAIN ANALYZE to see how MySQL executes a query — what indexes it uses, how many rows it scans, and the join strategy.
Use EXPLAIN or EXPLAIN ANALYZE to see how MySQL executes a query — what indexes it uses, how many rows it scans, and the join strategy.
EXPLAIN SELECT * FROM orders
WHERE customer_id = 42
AND status = 'shipped';
-- Key columns to check:
-- type: ref/range is good; ALL is a full table scan (bad)
-- key: which index is used
-- rows: estimated rows examined
A "type" of ALL in EXPLAIN means a full table scan — add an index.