SQL/MX Programming Manual for Java
SQL/MX Programming Considerations
HP NonStop SQL/MX Programming Manual for Java—523726-003
4-27
Similarity Check
Failed Timestamp Check
The SQL/MX executor performs a similarity check if a timestamp check fails, which
occurs if the table’s redefinition timestamp has changed since the referencing
statement was compiled. The SQL/MX executor performs a timestamp check for each
table referenced in an SQL statement at table open time (the first time the table is
opened). The timestamp check ensures that the current execution plan of an SQL
statement uses a valid definition of each table.
After the SQL/MX compiler has prepared the query execution plan of a statement,
changes to the tables that the plan processes can occur. For example, an index can be
added or removed, or a partition added. Changes of this nature can render the plan
inoperable. These types of changes to a table also change the redefinition timestamp
of the table.
Each table contains a redefinition timestamp in its file label. At compile time, the
timestamp of each table accessed by an SQL statement is stored with the compiled
plan of the statement in a module. When executing a plan, the SQL/MX executor
compares the current timestamp in the table’s file label with the compile-time
timestamp of the same table in the query execution plan. If the timestamps differ, the
SQL/MX executor initiates a similarity check, comparing the compile-time version to
the run-time version of the table, to determine if the query execution plan is still
operable. See Similarity Check Criteria on page 4-28.
Controlling the Similarity Check
By default, the similarity check is enabled for all DML statements. To disable the
similarity check and force recompilation of an SQL/MX statement when a class map
DEFINE value or table timestamp changes, use the CONTROL QUERY DEFAULT or
CONTROL TABLE statement with the SIMILARITY_CHECK option. For example, this
statement disables the similarity check for all tables in subsequent DML statements:
#sql {CONTROL QUERY DEFAULT SIMILARITY_CHECK 'OFF'};
This statement disables the similarity check for a specific table:
#sql {CONTROL TABLE $samdbcat.persnl.job
SIMILARITY_CHECK 'OFF'};
If you need to reenable the similarity check in the program, use the CONTROL QUERY
DEFAULT or CONTROL TABLE statement with the SIMILARITY_CHECK option set to
ON. For more information about coding CONTROL statements, see CONTROL
Statements on page 4-6.
Note. Although the SIMILARITY_CHECK option is enabled by default in SQL/MX, a DML
statement that refers to an SQL/MP table does not undergo a similarity check in SQL/MX if the
SQL/MP table was created with the SIMILARITY CHECK option disabled. To determine if the
similarity check is enabled for an SQL/MP table, check the SIMILARITYCHECK column for the
table in the TABLES table of the SQL/MP catalog. For more information, see the SQL/MP
Reference Manual.