SQL Programming Manual for TAL
Program Compilation and Execution
HP NonStop SQL Programming Manual for TAL—527887-001
5-11
Running the SQL Compiler
Statistics Information
For the SQL compiler to determine the best execution plan, it needs the current
statistics for any referenced tables. To provide these statistics, a database
administrator can use the UPDATE STATISTICS statement, which writes statistical
information about the tables in the catalog in which the table is registered. For more
information, see the UPDATE STATISTICS statement in the
SQL/MP Reference
Manual.
What Does the SQL Compiler Do?
When you SQL compile a program file, the SQL compiler performs these functions:
•
Resolves names. The compiler expands SQL object names, including TACL
DEFINE names, in the program using the current default volume, the current
catalog.
•
Checks object references in catalogs. The compiler checks the catalogs for SQL
object names to verify their existence and to read their descriptions. Then, the
compiler evaluates the object type and characteristics for each reference.
•
Determines an optimized execution plan. The compiler analyzes the SELECT,
INSERT, UPDATE, and DELETE statements to determine the best access paths
and join, sort, and blocking strategies for executing each statement. Then, the
compiler writes the object code for the execution plan to the program file.
•
Generates executable code. The compiler compiles the execution plan into
executable object code.
•
Stores information in catalogs. If the compilation is successful, the compiler
registers the program in the specified PROGRAMS catalog table and stores
dependencies in the USAGES table. The compiler also stores dependencies in the
USAGES catalog table of the catalogs where tables, views, and indexes that the
program uses are registered.
•
Marks the program file SQL sensitive and SQL valid. If the compilation is
successful, the compiler sets the SQL sensitive and SQL valid indicators in the
program's file label.
•
Generates a listing. The compiler writes the compiler listing (including any warning
or error messages) to the OUT file or device.
•
Estimates execution cost. For SQL DML statements, the compiler lists an estimate
for the cost of processing the statement based on the statistics in the catalogs.
•
Reports error and warning conditions. The compiler reports error and warning
conditions, as described under Interpreting SQL Compiler Messages
on page 5-14.