Reference · Cheat sheet
The one-page compressed essence: an index only seeks on the bare column compared to a matching-type constant.
A B-tree indexes the raw column values, in order. It can seek only when the query touches that bare column directly with a type-compatible constant. Wrap it, mistype it, or open the wildcard left → full scan.
| Killer | Example (ignored) | Fix |
|---|---|---|
| Function / expression on column | YEAR(created_at)=2026 |
Range rewrite created_at >= … AND < …, or a functional index |
| Leading wildcard | LIKE '%pat' |
Anchor it: LIKE 'pat%'; else FULLTEXT / reversed-column trick |
| Implicit type mismatch | str_col = 1 |
Match types: str_col = '1'; align join column types & collations |
| Low selectivity (not a bug) | status='active' (90% rows) |
Nothing — a scan is genuinely cheaper; or make it covering / composite |
LIKE 'pat%' | index used (range) |
LIKE '%pat' | ignored |
LIKE '%pat%' | ignored |
Source: MySQL 8.0 Manual — B-Tree/Hash Indexes (LIKE) · Type Conversion · Functional key parts · All lessons