Scalable Database Server, HiRDB Version 8 UAP Development Guide

[Contents][Index][Back][Next]

4.5.11 Deriving high-speed search conditions

A high-speed search condition refers to a condition derived from a WHERE clause search condition or an ON search condition in a FROM clause by CNF conversion or condition shifting. When high-speed search conditions are derived, the retrieval performance improves because the rows to be retrieved can be narrowed at an earlier stage.

When HiRDB derives high-speed search conditions, it retains the original search conditions used in the derivation. HiRDB can therefore generate just those derived conditions that are optimal conditions without generating derived conditions that cannot be used to narrow the search.

When HiRDB derives high-speed search conditions, it optimizes the search by considering the new derived conditions when it determines the access path (including the table retrieval method, join method, and join sequence). Therefore, when HiRDB derives high-speed search conditions, the access paths may change as described as follows:

When high-speed search conditions are derived from complex conditions, it takes longer to generate the high-speed search conditions and to evaluate the conditions when the search is executed. Therefore, depending on the SQL statements involved, the performance may actually drop instead of improve.

Organization of this subsection
(1) Application scope of high-speed search conditions
(2) Deriving high-speed search conditions by CNF conversion
(3) Deriving high-speed search conditions by condition shifting

(1) Application scope of high-speed search conditions

(a) UNIX version

Whether or not HiRDB derives high-speed search conditions depends on the specification values of the SQL optimization and SQL extension optimizing options. Table 4-16 shows the relationships between the SQL optimization and SQL extension optimizing options and deriving high-speed search conditions.

Table 4-16 Relationships between the SQL optimization and SQL extension optimizing options and deriving high-speed search conditions

Type Derivation source condition Derived condition Specified SQL optimization option or SQL extension optimizing option
Do not derive2 Derive only to foreign servers3 Derive 4
CNF conversion OR condition for one table Internal table One-table condition [Figure] [Figure] [Figure]
Foreign table1 One-table condition [Figure] [Figure] [Figure]
OR condition extending across two or more tables Internal table One-table condition [Figure] [Figure] G
Join condition (column=column) is extracted by OR reduction [Figure] [Figure] G
Other condition for two or more tables [Figure] [Figure] [Figure]
Confined to one foreign server1 One-table condition [Figure] [Figure] [Figure]
Join condition (column=column) is extracted by OR reduction [Figure] [Figure] G
Other condition for two or more tables [Figure] [Figure] [Figure]
Extends across multiple foreign servers or across foreign and internal tables1 Confined to internal tables One-table condition [Figure] [Figure] G
Join condition (column=column) is extracted by OR reduction [Figure] [Figure] G
Other condition for two or more tables [Figure] [Figure] [Figure]
Confined to one foreign server One-table condition [Figure] G G
Join condition (column=column) is extracted by OR reduction [Figure] G G
Other condition for two or more tables [Figure] G G
Extends across multiple foreign servers or across foreign and internal tables Join condition (column=column) is extracted by OR reduction [Figure] [Figure] G
Other condition for two or more tables [Figure] [Figure] [Figure]
Condition shifting Join condition for tables A and B, and condition for table A Tables A and B are internal tables One-table condition for table B [Figure] [Figure] G
Tables A and B are confined to one foreign server1 One-table condition for foreign table B [Figure] [Figure] [Figure]
Tables A and B extend across multiple foreign servers or across foreign and internal tables1 One-table condition for internal table B [Figure] [Figure] G
One-table condition for foreign table B [Figure] G G
Join condition for tables A and B, and join condition for tables A and C Tables A, B, and C are internal tables Join condition for tables B and C [Figure] [Figure] [Figure]
Tables A, B, and C are confined to one foreign table1 Join condition for tables B and C, which are confined to one foreign server [Figure] [Figure] [Figure]
Tables A, B, and C extend across multiple foreign servers or across foreign and internal tables1 Join condition for internal tables B and C [Figure] [Figure] [Figure]
Join condition for tables B and C, which are confined to one foreign server [Figure] G G
Join condition for tables B and C, which extend across two foreign servers or across foreign and internal tables [Figure] [Figure] [Figure]

Legend:
G: HiRDB generates high-speed search conditions.
[Figure]: HiRDB does not generate high-speed search conditions.

Note
An internal table refers to one of the following types of tables:
  • Any table when HiRDB External Data Access is not installed
  • A non-foreign table when HiRDB External Data Access is installed

1 This condition applies when HiRDB External Data Access is installed.

2 In the SQL extension optimizing options, specify the value for suppressing derivation of unconditionally created high-speed search conditions for foreign server execution. However, this option specification becomes invalid if the value for deriving high-speed search conditions is specified concurrently in the SQL optimization options.

3 Do not concurrently specify the value for suppressing derivation of unconditionally created high-speed search conditions for foreign server execution in the SQL extension optimizing options and the value for deriving high-speed search conditions in the SQL optimization options.

4 Specify the value for deriving high-speed search conditions in the SQL optimization options.
(b) Windows version

High-speed search conditions are generated when you specify the value for deriving high-speed search conditions in the SQL optimization options. Table 4-17 shows the relationships between the SQL optimization options and deriving high-speed search conditions.

Table 4-17 Relationships between the SQL optimization options and deriving high-speed search conditions

Type Derivation source condition Derived condition Specified SQL optimization option (derives high-speed search conditions)#
CNF conversion OR condition for one table One-table condition [Figure]
OR condition extending across two or more tables One-table condition G
Join condition (column=column) is extracted by OR reduction G
Other condition for two or more tables [Figure]
Condition shifting Join condition for tables A and B, and condition for table A One-table condition for table B G

Legend:
G: HiRDB generates high-speed search conditions.
[Figure]: HiRDB does not generate high-speed search conditions.

#
Specify the value for deriving high-speed search conditions in the SQL optimization options.

(2) Deriving high-speed search conditions by CNF conversion

CNF conversion refers to converting conditions joined with OR (disjunctive normal form (DNF) format) into equivalent conditions joined with AND (conjunctive normal form (CNF) format). High-speed search conditions can be derived by applying CNF conversion to WHERE clause search conditions or to ON search conditions in FROM clauses.

(a) Search conditions derived by CNF conversion

The following search conditions are derived by CNF conversion:

Furthermore, the specifications for the SQL optimization options and SQL extension optimizing options determine whether HiRDB derives high-speed search conditions. For details about the relationships between SQL optimization options and SQL extension optimizing options, and deriving of high-speed search conditions, see (1) Application scope of high-speed search conditions.

(b) Conditions when CNF conversion is not executed

High-speed search conditions are not derived by CNF conversion if any one of the following conditions applies:

(3) Deriving high-speed search conditions by condition shifting

Condition shifting refers to deriving a new condition from two or more conditions.

The methods of deriving search conditions by condition shifting are described as follows.

Furthermore, the specifications for the SQL optimization options and SQL extension optimizing options determine whether HiRDB derives high-speed search conditions. For details about the relationships between SQL optimization options and SQL extension optimizing options, and deriving of high-speed search conditions, see (1) Application scope of high-speed search conditions.

(a) Deriving high-speed search conditions by shifting a one-table condition through a join condition

If the search conditions consist of a two-table join condition (column=column only) and a one-table condition that includes the join column, HiRDB derives a one-table condition for the column in the table to be joined. An example is shown as follows:

 
T1.C1 = T2.C1 AND T1.C1 > 10
[Figure]T1.C1 = T2.C1 AND T1.C1 > 10 AND T2.C1 > 10
 

The underlined section becomes the derived high-speed search condition.

 
(b) Deriving high-speed search conditions by shifting join conditions (applicable to the UNIX version only)

If the search conditions consist of a two-table join condition (column=column only) and a join condition (column=column only) between a column in one of the two tables and a column in a separate third table, HiRDB derives a new join condition from the remaining two columns that are not linked by a join condition. If correlation names are specified, the tables are viewed as separate tables if the correlation names are different. An example is shown as follows:

 
T1.C1 = T2.C1 AND T2.C1 = T3.C1
[Figure]T1.C1 = T2.C1 AND T2.C1 = T3.C1 AND T1.C1 = T3.C1
 

The underlined section is the rapid search condition that was derived.