How MySQL Implicit Type Conversion Turned an Indexed Query Into a 7M-Row Scan
It was supposed to be a standard, run-of-the-mill maintenance task—the kind of routine database housekeeping that backend engineers perform dozens of times a month without a second thought. A small batch of customer account records needed a minor state update so they could be placed back into the queue for reassignment. No complex migrations, no structural database refactoring, and certainly no high-stakes schema changes. Just a simple UPDATE statement.
Yet, in a high-scale production environment, "simple" is a dangerous word. It is a word that breeds complacency.
Before executing the script against our production cluster, I took a step that every engineer should treat as a muscle reflex: I prefix-checked the query with EXPLAIN to see the query execution plan. When the output returned, my screen lit up with an alarming warning sign. The database was planning to scan over seven million rows just to modify a handful of records.
...
Copyright of this story solely belongs to hackernoon.com. To see the full text click HERE