When TABLE-SCAN is not recommended to be used
- Last Updated: January 17, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Example 1: The following example demonstrates when TABLE-SCAN is
not recommended instead of WHOLE-INDEX
|
When TABLE-SCAN is used on non WHOLE-INDEX,
the AVM returns a compiler warning stating: "Using a TABLE-SCAN option
on non WHOLE-INDEX query". During the runtime,
the AVM uses a TABLE-SCAN instead of the nameix
index, which would be more efficient.
Example 2: TABLE-SCAN keyword with BY expression, where expression is defined by an index
|
In this case, the AVM returns a compiler warning stating: "Using
a TABLE-SCAN option with BY expression
which would have been optimized using the index that matches BY".
When you specify the TABLE-SCAN option, the AVM
scans the table to sort the records by the id column,
and then displays each record. If you do not specify the TABLE-SCAN option,
the AVM scans the entire table once, and sorting is not required
as the id column has already been indexed.
Keep in mind the following when using TABLE-SCAN:
-
TABLE-SCANprovides the most efficient access method when retrieving rows of a temp-table or a database table in a Type II Storage area. If the table is of a Type I storage, the AVM ignores theTABLE-SCANoption and uses theUSE-INDEXkeyword to perform the scan. - To increase the performance of the
EMPTY-TEMP-TABLEmethod and statement, theTABLE-SCANoption is turned on by default. - Do not use
TABLE-SCANon a nonWHOLE-INDEXquery. For example, if the query has "WHEREcustnum > 100" and custnum has an index, the AVM does not require to scan the whole table to satisfy the query. See also When TABLE-SCAN is not recommended to be used. - Do not use the
TABLE-SCANoption inFOR EACHstatements, if theBYexpression option is specified and the expression is defined by the index. If you specify theTABLE-SCANoption, the AVM sorts all the records by expression. The AVM does not need to perform the sorting, as the expression column already has a sorted index. See also When TABLE-SCAN is not recommended to be used. - Avoid using the
TABLE-SCANoption on any child table in a given join query, because theWHOLE-INDEXis not used to access the child table’s records.