索引合并查询是指将多个范围扫描合查询的结果合并为一个结果集。索引合并这种访问方式适用于单表查询,不适用与多表查询。在查询的时候会产生并集、交集或者是交并集的操作。
索引合并查询的例子
SELECT * FROM tbl_name WHERE key1 = 10 OR key2 = 20; SELECT * FROM tbl_name WHERE (key1 = 10 OR key2 = 20) AND non_key = 30; SELECT * FROM t1, t2 WHERE (t1.key1 IN (1,2) OR t1.key2 LIKE 'value%') AND t2.key1 = t1.some_col; SELECT * FROM t1, t2 WHERE t1.key1 = 1 AND (t2.key1 = t1.some_col OR t2.key2 = t1.some_col2);
https://dev.mysql.com/doc/refman/5.5/en/index-merge-optimization.html