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:

On z/OS, 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:

  • The DEFINE compiler compiles only those expressions that are found in DEFINE fields referenced in TABLE requests, but it provides much faster execution of those expressions than the other compiler. It compiles expressions using the arithmetic operations built into the underlying operating system, and is, therefore, referred to as the native compiler. Compilation takes place at TABLE run time. This compiler is invoked by issuing the command SET DEFINES = COMPILED.
  • The other compiler is invoked with the command SET COMPUTE = NEW. This compiler 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.

Among the benefits of the DEFINE compiler are:

  • Compilation of only those expressions that are actually used in the TABLE request.
  • Much faster execution of expressions containing complex calculations on long packed fields.
  • Compilation of date expressions.

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.



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.

OLD

Leaves expression compilation up to the control of the current SET COMPUTE value. OLD is the default 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


x
Compiling Expressions Using the COMPUTE Parameter

How to:

Reference:



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:

  • Calculations that involve any function (for example, user functions), except for EDIT, DECODE, and LAST.
  • Calculations that test for existing data (IF field IS-NOT MISSING) or that result in a missing field (TEMP/A4 MISSING ON= ...).
  • Calculations that involve fields with date formats. (See the table of date formats in the FORMAT attribute description in the Describing Data With WebFOCUS Language manual.)
  • Calculations that use exponentiation (10**2).


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:

  • Issuing the SET DEFINES=COMPILED command activates the new compiler and deactivates the old compiler by automatically setting the value of the COMPUTE parameter to NATV (native compiler).
  • Issuing the SET DEFINES=OLD command deactivates the new compiler and automatically activates the old compiler by automatically setting the value of the COMPUTE parameter to NEW .
  • Issuing the SET COMPUTE command with either the OLD or NEW setting deactivates the new compiler. The OLD setting also deactivates the old 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
  • Any expression that cannot be compiled runs without compilation. This does not affect compilation of other expressions. The following elements in an expression disable compilation with the new compiler:
    • Functions. However, expressions that use the following functions can be compiled: YMD, DMY, INT, and DECODE.
    • CONTAINS, OMITS, LAST.
  • The SET DEFINES command is not supported in an ON TABLE phrase.

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.


WebFOCUS