MySQL Tuning Past the Index Fix: Explain Estimates, Change Buffer, and Flush Stalls
A production MySQL shop eventually hits every one of these failure modes, and each produces a misleading symptom: fluctuating latency, a plan that looks wrong, or a query that stalls mid-day. Knowing which knob to turn and which index pattern actually helps beats guessing from explain output alone.
Stacking indexes does not fix a slow database. The execution layer decides most of the pain: explain's scan counts are sampling-based estimates that drift from reality, and the optimizer can prefer an index that scans more rows when it avoids a table lookup. When the estimate diverges, the working moves are analyze table, force index, rewriting the SQL, or rebuilding a misleading index.
Index design carries most of the remaining gain. Covering and composite indexes cut table lookups, index pushdown (5.6+) filters inside index traversal, and the change buffer only serves non-unique indexes, so it suits bill and log workloads but hurts read-after-write ones. Prefix indexes save space on long fields, and any function, implicit type conversion, or character set cast on an indexed column silently disables the index.
Flush behavior is the other stall source. When the redo log fills, updates pause while the checkpoint advances, which is a common cause of intermittent production stalls. Setting innodb_io_capacity from a fio IOPS test gives InnoDB an honest disk budget, and MySQL 8.0 already defaults innodb_flush_neighbors to 0 because neighbor flushes only pay off on mechanical disks.
The optimizer's cost model, not raw row counts, decides index selection, which is why explain output alone misleads developers into thinking the chosen plan is wrong.
Every index-destroying trap in the article collapses to one rule: any function applied to an index column, including ones injected implicitly, kills the index.
The choice between normal and unique indexes is a workload decision, not a correctness one, since only the change buffer's deferral path changes.