MySQL optimizer_trace: The Microscope for Wrong Plan Decisions
EXPLAIN tells you which plan MySQL chose; optimizer_trace tells you which plans it rejected and why. Per-session capture, reading considered_execution_plans, cost numbers, truncation traps, and a worked wrong-index case.