An 使用单个键的OR using a single key is well optimized, as is the handling of AND.OR和AND的处理都得到了很好的优化。
The one tricky case is that of searching on two different keys combined with 一个棘手的情况是在两个不同的键上结合OR:OR进行搜索:
SELECT field1_index, field2_index FROM test_table WHERE field1_index = '1' OR field2_index = '1'
This case is optimized. See Section 8.2.1.3, “Index Merge Optimization”.这个案例是经过优化的。参见第8.2.1.3节,“索引合并优化”。
You can also solve the problem efficiently by using a 您还可以通过使用UNION that combines the output of two separate SELECT statements. UNION来高效地解决这个问题,UNION将两个单独的SELECT语句的输出组合在一起。See Section 13.2.10.3, “UNION Clause”.请参阅第13.2.10.3节,“UNION子句”。
Each 每个SELECT searches only one key and can be optimized:SELECT只搜索一个关键字,并且可以进行优化:
SELECT field1_index, field2_index
FROM test_table WHERE field1_index = '1'
UNION
SELECT field1_index, field2_index
FROM test_table WHERE field2_index = '1';