Compiling Expressions

In this section:

Compiling expressions into machine code provides faster processing.


Top of page

x
Compiling Expressions Using the DEFINES Parameter

How to:

Two expression compilers are available. By issuing the appropriate command, you can select one of them or disable compilation of expressions. Both compilers cannot be active for the same request:

Among the benefits of the DEFINE compiler are:

After the native DEFINE compiler is invoked, any request that uses a DEFINE expression causes the expression to be compiled and then loaded into the system. For each record of the request that needs computation, the system executes the generated code. This compiler is most effective with TABLE requests that include a large number of DEFINE fields and read a large number of records because the speed of evaluation per record in such requests offsets the extra compilation and load steps.

Note: To compile expressions in MODIFY procedures in Mainframe environments, use the SET MODCOMPUTE command.



x
Syntax: How to Compile DEFINE Expressions

Issue the following command FOCPARM, a FOCEXEC, or at the command line:

SET DEFINES = {COMPILED|OLD}

where:

COMPILED

Implements expression compilation at request run time, compiling only those DEFINEs that are used in the request. COMPILED is the default value.

OLD

Leaves expression compilation up to the control of the current SET COMPUTE value. If you issue the SET DEFINES = OLD command, the COMPUTE parameter is automatically set to NEW.



x
Syntax: How to Query Compiled DEFINE Expressions

Issue the following command to query the current setting:

? SET DEFINES

Top of page

x
Compiling Expressions Using the COMPUTE Parameter

How to:

Reference:

The compiler implemented with the SET COMPUTE = NEW command provides expression compilation for DEFINE, IF, and WHERE commands in TABLE procedures. Under this compiler, expressions are compiled at DEFINE time. Therefore, compilation may be invoked for expressions that are never actually used in a request.



x
Syntax: How to Control Expression Compilation Using the COMPUTE Parameter
SET COMPUTE = {NEW|OLD|NATV}

where:

NEW

Compiles DEFINE calculations when a request is executed.

OLD

Does not compile DEFINE calculations when a request is executed. The old logic is used.

NATV

Compiles DEFINE calculations using the native compiler. This setting is also activated by the SET DEFINES=COMPILED command, which is the default setting.



x
Reference: Usage Notes for SET COMPUTE

The following calculations are not compiled with SET COMPUTE = NEW:



x
Reference: Interaction Between SET DEFINES and SET COMPUTE

Two expression compilers are available, but only one can be activated for any request. Activating either compiler automatically deactivates the other compiler:

Therefore, you can select either compiler by issuing the SET DEFINES command. DEFINES=COMPILED selects the new compiler, DEFINES=OLD selects the old compiler. To turn compilation off, issue SET COMPUTE=OLD.

The new compiler is recommended for TABLE requests that include a large number of DEFINE fields (especially those that use packed arithmetic or date expressions) and read a large number of records.

If a TABLE request retrieves a large number of records or if the DEFINE fields use packed arithmetic (especially with long packed fields) or date expressions, the new compiler is likely to provide the most benefit.



x
Reference: Usage Notes for Compiled DEFINEs

If compilation is not possible because of environmental conditions, the processing is handled without compilation. No message is generated indicating that compilation did not take place. To determine whether it did take place, issue the ? COMPILE command.


Information Builders