一条 SQL 是有可能用多个索引的
索引合并 - index merge
The Index Merge access method retrieves rows with multiple
rangescans and merges their results into one. This access method merges index scans from a single table only, not scans across multiple tables. The merge can produce unions, intersections, or unions-of-intersections of its underlying scans.MySQL 5.1 引入, 适用于一张表内, 合并多个
range索引扫描的结果, 来优化查询
EXPLAIN 输出
type: 显示index_mergekey: 包含使用到的索引key_len: 以列表形式展示每个合并索引中最长键部分的长度Extra: 三种算法Using intersect(...)Using union(...)Using sort_union(...)