SQL Programming Manual for TAL

Program Compilation and Execution
HP NonStop SQL Programming Manual for TAL527887-001
5-25
Predicting Automatic SQL Recompilation
If automatic SQL recompilation is enabled, these events can trigger a recompilation:
SQL load time
Table open time
A new TACL DEFINE at SQL load time
An unavailable access path (index)
The attempted execution of an uncompiled SQL statement
SQL Load Time
SQL load time occurs when the first SQL statement in a program is executed. These
conditions can cause automatic recompilation at SQL load time:
If the SQL valid flag is set to invalid, recompilation occurs. Automatic recompilation
of an invalid program file occurs each time the program runs.
If the set of TACL DEFINEs at run time is different from the set used when you
explicitly compiled the program.
To control the extent of recompilation at SQL load time, use the SQLCOMP command
RECOMPILEALL or RECOMPILEONDEMAND option. For automatic recompilation of
the entire program, use the RECOMPILEALL option (which is the default). To limit
automatic recompilation to only statements that are actually executed, use the
RECOMPILEONDEMAND option.
Table Open Time
When the SQL executor accesses a table, an SQL statement is automatically
recompiled if the timestamp for the table is different than the timestamp for the last
SQL compilation of the statement.
Usually, the SQL executor opens a table the first time the program executes an SQL
statement that refers to the table. The executor then leaves the table open until the
program stops. DDL and database utility operations on the table (or on a dependent
index) cause the table to be closed and the timestamp of the table to be updated.
When the SQL statement that uses the table executes again and the table has been
closed, the executor compares the timestamp of the new statement to the timestamp of
the table and recompiles the statement, if necessary.
Only the specific SQL statement is automatically recompiled when the timestamp
check reveals a discrepancy with the table timestamp.
New TACL DEFINEs
If the set of TACL DEFINEs at run time is different from the set when you explicitly
compiled the program and you specified the SQLCOMP command
RECOMPILEONDEMAND option, the statement is recompiled. The compiler uses the