前言 mysql的索引合并并不是什么新特性.早在mysql5.0版本就已经实现.之所以还写这篇博文,是因为好多人还一直保留着一条sql语句只能使用一个索引的错误观念.本文会通过一些示例来说明如何使用索引合并. 什么是索引合并 下面我们看下mysql文档中对索引合并的说明: The Index Merge method is used to retrieve rows with several range scans and to merge their results into one. The…
使用explain查看执行计划, 下面是针对这两条语句进行分析,其查询结果是一样的. EXPLAIN select n.id,n.title from info n inner join info_tags t on n.id=t.info_id where t.category_id=20 order by id desc limit 8; EXPLAIN select n.id,n.title from info n inner join (select info_id as id from…