SQL Programming Manual for Pascal
Program Compilation and Execution
HP NonStop SQL Programming Manual for Pascal—528614-001
5-24
Understanding Automatic SQL Recompilation
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. 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.
Automatic SQL recompilation does the following:
•
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 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 SQLCA, if it is declared.
When an SQL statement is recompiled, the SQL compiler uses the default volume and
catalog that were used for the explicit compilation, and the DEFINEs that were set
when the first SQL statement in a program was executed.
Automatic SQL recompilation can sometimes cause performance degradation of the
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, when you want to enable or disable automatic recompilation), see the NonStop
SQL Installation and Management Manual.
If automatic SQL recompilation is enabled, the following events can trigger a
recompilation:
•
SQL load time—the time at which the first SQL statement in a program is executed