NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
S-76
Statistics
The following is an example of a static SQL statement from a COBOL85 program:
EXEC SQL
SELECT LAST_NAME, EMPNUM INTO :LNAME, :EMPNUM
FROM EMPLOYEE WHERE DEPTNUM = 200
END-EXEC.
The following is an example of a static SQL statement from a C, Pascal, or TAL
program:
EXEC SQL
SELECT LAST_NAME, EMPNUM INTO :LNAME, :EMPNUM
FROM EMPLOYEE WHERE DEPTNUM = 200;
Statistics
SQL has an UPDATE STATISTICS statement you can use to collect and save statistics
on columns and tables. The SQL compiler uses these statistics to determine the
selectivity of predicates, indexes, and tables. Because selectivity directly influences the
cost of access plans, regular collection of statistics increases the likelihood that SQL will
choose efficient access plans.
A NonStop SQL/MP installation should follow these rules for updating statistics:
Do not use the UPDATE STATISTICS statement until you use FILEINFO with the
STATISTICS option to see if performance problems are caused by fragmentation.
By using FILEINFO, you should be able to determine if the performance is being
impeded by fragmentation of blocks in a table. In that case, running UPDATE
STATISTICS and recompiling the queries does not help. You should first reload the
table online, by using the FUP RELOAD command.
Determine the effect of UPDATE STATISTICS on production queries first. In an
SQLCI session, issue a BEGIN WORK command and then issue UPDATE
STATISTICS. Use EXPLAIN to see if the new statistics would give you the correct
query plan. The UPDATE STATISTICS and EXPLAIN commands should be issued
within a transaction so that the UPDATE STATISTICS operation can be backed out
easily if necessary.
Specify the NORECOMPILE option in the UPDATE STATISTICS statement so that
dependent programs are not invalidated. By default, an UPDATE STATISTICS
operation invalidates dependent programs. Even if UPDATE STATISTICS is
executed within a transaction that can be backed out, if the NORECOMPILE option
is omitted, dependent programs are still invalidated because program file labels are
not audited. Updates to program file labels are not backed out.
Storage Management Foundation (SMF)
The Serverware Storage Management Foundation (ServerWare SMF) subsystem is an
optional Tandem product. ServerWare SMF simplifies name, storage, and file