Command SET OPTIMIZE Foundation
Enables/Disables expression optimizer of database-kernel
SET OPTIMIZE ON | off | <lToggle>
With SET OPTIMIZE ON, the database kernel analyzes and executes expressions defined for a work area using its specialized expression optimization engine. This affects all commands and functions that usually specify a subset of database records via a logical expression, such as SET FILTER, or all database commands and functions supporting a FOR or WHILE clause, such as DbEval() or DbLocate().
The optimized expression engine knows exactly to which work area an expression belongs and which database engine is involved. As a consequence, an expression is typically executed two times faster than without optimization. In addition, the expression optimizer uses its knowledge about the data model to rearrange complex and compound expressions, thus reducing the workload or CPU usage.
If optimization is set to OFF, or .F. (false), all expressions are executed in the traditional way by the generic code block execution machine of the Xbase++ kernel. This provides for highest flexibility and access to enhanced features like detached locals, late-binding of hosting variables and embedding of user-defined functions. This generic approach, however, leads to "higher costs" for determining the result of an expression. This can lead to a reduced performance, especially in the context of database operations where the result of the expression is often of logcial type, or the expression gains its values from the current database record only.
The setting defaults to ON since the expression optimizer detects if an expression includes detached locals or user-defined functions and then switches automatically to code block execution.
More details about the different optimization technologies and their dependecies can be found at SET RUSHMORE.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.