Oracle 5.0 Reference Manual page 681

Table of Contents

Advertisement

Using union(...)
Using sort_union(...)
The following sections describe these methods in greater detail.
The choice between different possible variants of the Index Merge access method and other access
methods is based on cost estimates of various available options.
8.3.1.4.1. The Index Merge Intersection Access Algorithm
This access algorithm can be employed when a
conditions on different keys combined with
• In this form, where the index has exactly
key_part1=const1
• Any range condition over a primary key of an
Examples:
SELECT * FROM
SELECT * FROM
WHERE (key1_part1=1 AND key1_part2=2) AND key2=2;
The Index Merge intersection algorithm performs simultaneous scans on all used indexes and
produces the intersection of row sequences that it receives from the merged index scans.
If all columns used in the query are covered by the used indexes, full table rows are not retrieved
(EXPLAIN
output contains
query:
SELECT COUNT(*) FROM t1 WHERE key1=1 AND key2=1;
Optimizing
Note
The Index Merge optimization algorithm has the following known deficiencies:
• If your query has a complex
nesting and MySQL doesn't choose the optimal plan, try distributing terms
using the following identity laws:
(x
AND y) OR
z
=
(x
OR y) AND
z
=
• Index Merge is not applicable to full-text indexes. We plan to extend it to
cover these in a future MySQL release.
• If a range scan is possible on some key, the optimizer will not consider using
Index Merge Union or Index Merge Sort-Union algorithms. For example,
consider this query:
SELECT * FROM t1 WHERE (goodkey1 < 10 OR goodkey2 < 20) AND badkey < 30;
For this query, two plans are possible:
• An Index Merge scan using the
condition.
• A range scan using the
However, the optimizer considers only the second plan.
AND
key_part2=const2
innodb_table
WHERE
primary_key
tbl_name
Using index
Statements
SELECT
clause with deep
WHERE
(x
OR z) AND
(y
OR z)
(x
AND z) OR
(y
AND z)
(goodkey1 < 10 OR goodkey2 < 20)
badkey < 30
clause was converted to several range
WHERE
[880], and each condition is one of the following:
AND
parts (that is, all index parts are covered):
N
... AND
key_partN=constN
or
InnoDB
BDB
< 10 AND key_col1=20;
in
field in this case). Here is an example of such a
Extra
661
AND [880]/OR
condition.
table.
[881]

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents