Why SELECT * Is the Enemy of a Covering Index: The Three-Gate Chain of MySQL Index Optimization
Millisecond queries and full scans on the same index come down to three sequential gates; reading them as a chain makes EXPLAIN a direct debugging tool instead of a guessing game. For backend engineers and anyone tuning MySQL, this is what separates a fast query from a random-IO storm that thrashes the buffer pool.
On a single composite index, three queries that all appear to use the index can vary from millisecond response to full table scan. The cause is a chain of three decisions: leftmost prefix determines whether the index is usable at all, a covering index determines whether the server can return results without going back to the clustered index, and index condition pushdown lets the storage engine filter rows before that row lookup occurs.
The practical takeaway is that SELECT * is the natural enemy of a covering index. An index can only cover a subset of columns, so a star query always triggers a random IO trip per row. The recommended approach is to cover only the two or three highest-frequency columns, not to pad an index with eight columns that bloats it larger than the data.
Index condition pushdown, introduced in MySQL 5.6, reduces the number of row lookups, not the number of index entries scanned. It works only for secondary indexes and only when the filter column exists in the index. EXPLAIN fields key, type, and Extra pinpoint which gate failed, turning the tuning puzzle into a checklist.
Leftmost prefix, covering index, and ICP work better as a progressive chain than as three isolated features; that framing explains why a query can be slow even when an index is technically used.
"Using an index" is not a yes/no state; the same index can produce millisecond results, slow row lookups, or a full scan depending on which gate in the chain fails.
Over-covering an index with many columns trades read speed for write speed and index size; the article's rule of covering only two or three hot columns keeps that balance.
This article's framing of linking the three concepts into an "IO-saving chain" is spot on. Let me add four points that matter more in practice: 1) The most valuable benefit of a covering index is often not avoiding the table lookup but avoiding filesort. Putting the sort column of `ORDER BY create_time DESC LIMIT 20` into the index (index order = sort order) can eliminate both the table lookup and filesort at once. This yields much greater gains than tuning ICP, but few people think about it when designing indexes. 2) The cost of `SELECT *` on a wide table is not limited to table lookup. If there are TEXT/BLOB columns, InnoDB stores large fields on off-page overflow pages, requiring an additional page read—and this happens **for each row**. At this point, the difference between "one table lookup" and "table lookup + N overflow page reads" is an order of magnitude, and `EXPLAIN` cannot show that at all. 3) `type=ref` does not imply a small number of rows. `rows` is estimated from statistics; when sampling is inaccurate, the estimate can be off by orders of magnitude. To judge the actual cost, use `EXPLAIN ANALYZE` (8.0.18+), which gives the actual row count and actual execution time. I got burned once: `rows=3` actually scanned 40,000 rows because the statistics hadn't been updated for a week. 4) `Using index` and `Using index condition` can appear together (`Using index; Using index condition`); they are not mutually exclusive. I'd suggest adding to the article's quick-reference table: seeing both together means covering index and index condition pushdown are both in effect—that's the best case. Finally, a trap related to the leftmost prefix in the article: in `WHERE name LIKE '张%' AND age = 20`, `age` cannot be used for positioning, but if you write `age = 20 AND name LIKE '张%'`, the optimizer will still pick the correct index—**the order does not affect whether it can be used, only how clear it is to read**. What truly matters is "which column can form a contiguous leftmost prefix."