Bracketing
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Having selected one or more indexes to satisfy a query, the AVM tries immediately to isolate the smallest necessary index subset, so as to return as few records as possible. This is called bracketing. Careful query design can increase the opportunities for bracketing, thereby preventing ABL from scanning entire indexes and examining all records. The rules for bracketing are simple:
- Bracket on active equality matches.
- Bracket an active range match, but no further brackets are possible for that index.
The following table provides some bracketing examples:
| Sample WHERE clause | Indexes used | Brackets |
|---|---|---|
|
Cust-Num | None |
|
Cust-Num | None |
|
Name | Name |
|
Sales-Rep | Sales-Rep |
|
Country-Post | Country-Post |
|
Comments Country-Post | Country Postal-Code |
The following recommendations are intended to help you maximize query performance. They are only recommendations, and you can choose to ignore one or more of them in specific circumstances:
- Avoid joining range matches with
AND. - Avoid
ORs if any expression on either side of theORdoes not use an index (or all its components). Be aware that the AVM must scan all records using the primary index. - With word indexes, avoid using
ANDwith two wild card strings, either in the same word index (WHEREcommentsCONTAINS“fast* & grow*”) or in separate word indexes (WHEREcommentsCONTAINS“fast*”ANDreportCONTAINS“ris*”). - Avoid
WHEREclauses thatORa word index reference and a non-indexed criterion (WHEREcommentsCONTAINS“computer”ORaddress2 = “Bedford”).