SQL Programming Manual for TAL
Program Compilation and Execution
HP NonStop SQL Programming Manual for TAL—527887-001
5-24
Understanding Automatic SQL Recompilation
Therefore, an invalid program file is sometimes marked as SQL valid. NonStop SQL
allows this discrepancy to provide local autonomy in database management
operations. An invalid program that is erroneously marked valid is detected at run time
by a timestamp check and automatically recompiled.
Understanding Automatic SQL Recompilation
Automatic SQL recompilation is the run-time compilation, invoked by the SQL executor,
of an entire program file or a single SQL statement in a program file. The functions of
automatic SQL recompilation are:
•
Determines the most efficient access to a database by ensuring that an execution
plan uses the current description of the database (this execution plan remains in
effect until the program stops or another SQL recompilation occurs)
•
Maximizes database availability and node autonomy by generating a new
execution plan at run time if the currently compiled plan cannot work because a
required index is unavailable
•
Allows a program to refer to database objects that did not exist during explicit SQL
compilation
•
Allows a program to use different sets of TACL DEFINEs to specify different
databases (for example, a development database and a production database)
If the SQL recompilation is successful, the program file or SQL statement executes. If
the recompilation fails, NonStop SQL returns an error to the SQLCODE variable and
the SQL communication area (SQLCA), if it is declared.
Several considerations for automatic SQL recompilation are:
•
Automatic SQL recompilation does not validate the program file itself; it validates
only the copy of the file in memory. Only explicit SQL compilation validates an
invalid program file.
•
When an SQL statement is recompiled, the SQL compiler uses the default volume
and catalog that were used for the explicit compilation and the TACL DEFINEs set
from SQL load time (described under SQL Load Time
on page 5-25).
•
Automatic SQL recompilation can cause the performance degradation of a
program. For the best performance, run valid program files that do not need to be
recompiled.
Predicting Automatic SQL Recompilation
You can enable or disable automatic SQL recompilation when you explicitly SQL
compile a program file. When you enter the SQLCOMP command, use the
RECOMPILE option (which is the default) to enable automatic SQL recompilation and
the NORECOMPILE option to disable it. For application management considerations
(that is, whether you want to enable or disable automatic recompilation), see the
SQL/MP Installation and Management Manual.