Case 3: WHERE searchExpr OR searchExpr
- Last Updated: January 17, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
For a compound WHERE clause, ABL builds
a logic tree and evaluates index usage on either side of the OR.
In general, if all selection criteria on both sides of the OR include
matches—equality, range, or sort—on successive, leading components
of two non-unique indexes, ABL uses both indexes:
| Sample WHERE clause | Indexes used |
|---|---|
|
Comments Name |
|
Name Country-Post |
In addition, if one side of the OR includes
a CONTAINS clause (that is, it uses a word index),
ABL uses the word index and then a second index to satisfy the other
side of the OR:
|
Comments Cust-Num |
In this example, the right side of the OR includes
a range match, but Postal-Code is the second component
of the County-Post index, so the match is not active. ABL uses the
primary index to satisfy this piece of the query and, as always,
uses the word index to satisfy a CONTAINS clause
as shown in this example:
|
Comments Sales-Rep |
If the selection criteria do not support multiple index usage, see the General rules for choosing a single index.
OR does not
use an index or all its components, ABL must scan all records using
the primary index.