摘要: order by主要优化出现filesort的情况,以下情况可以使用索引. 1.order by 字段都来自驱动表且满足索引的最左前缀. select a from test order by a,b 2.当order by字段不是最左前缀时,如果字段前的字段为常量则可以利用. select a f 阅读全文
posted @ 2017-08-07 16:03 liron 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 优化group by查询的时候,一般的会想到两个名词:松散索引扫描(Loose Index Scan)和紧凑索引扫描(Tight Index Scan),因为通过这两种索引扫描就可以高效快速弟完成group by操作。 松散索引扫描(Loose Index Scan): 松散索引扫描只需要读取很少量 阅读全文
posted @ 2017-08-07 15:45 liron 阅读(1448) 评论(0) 推荐(0) 编辑
摘要: 1.select_type simple :它表示简单的select,没有union和子查询 dependent union:union依赖外层的查询 dependent subquery:subquery依赖外层的查询 2.type system:表仅有一行,这是const类型的特列,平时不会出现 阅读全文
posted @ 2017-08-07 12:19 liron 阅读(6374) 评论(0) 推荐(0) 编辑