Extra 速查
| 值 | 含义 | 方向 |
|---|---|---|
| Using index | 覆盖索引,不回表 | 好 |
| Using index condition | 索引条件下推(ICP) | 好 |
| Using where | 需要回表后过滤 | 中性 |
| Using filesort | 额外排序(不一定落盘) | 优化排序索引 |
| Using temporary | 临时表(常见于 GROUP BY/DISTINCT) | 审视写法 |
| Using join buffer (hash join) | 被驱动表无索引 | 加索引或调 buffer |
定位排序问题
定位排序问题
EXPLAIN SELECT * FROM appdb.orders WHERE user_id = 1
ORDER BY created_at DESC LIMIT 20;
-- Extra: Using filesort => 考虑 (user_id, created_at) 联合索引filesort 不一定落磁盘:小结果集在内存排也很快,先看数据规模再优化。