Link Sub-Clauses
A link sub-clause is a sub-clause that:
- References more than two tables
Or:
- References two tables but cannot be used as an access sub-clause (as it does not meet the criteria for an access sub-clause).
When the Query Processor has identified the link clauses in a query, it stores them temporarily in an internal list. Later in the optimization algorithm, the Query Processor will assign each of the link sub-clauses to a filter condition for an appropriate table. The table that is chosen is:
- One of the tables that is referenced by the link sub-clause in your query
- The right-most table in the table order (as calculated by the Query Processor).
The link sub-clauses are assigned for every permutation of the table order (see Calculate the Table Order Permutations).
Example:
When the Query Processor has categorized the sub-clauses in a query, it begins to calculate the permutations for the table order. For each permutation, the Query Processor assigns the link sub-clauses to the right-most table in the table order. So, if a query is used to search three tables (Table A, Table B, and Table C) and the query contains a link sub-clause that references Table B and Table C, the link sub-clause will be assigned to each permutation as follows:
- A,B,C
The link sub-clause is allocated to Table C as, in this order, Table C is the right-most table that is referenced by the sub-clause.
- A,C,B
The link sub-clause is allocated to Table B as, in this order, Table B is the right-most table that is referenced by the sub-clause.
- B,A,C
The link sub-clause is allocated to Table C as, in this order, Table C is the right-most table that is referenced by the sub-clause.
- B,C,A
The link sub-clause is allocated to Table C as, in this order, Table C is the right-most table that is referenced by the sub-clause.
- C,A,B
The link sub-clause is allocated to Table B as, in this order, Table B is the right-most table that is referenced by the sub-clause.
- C,B,A
The link sub-clause is allocated to Table B as, in this order, Table B is the right-most table that is referenced by the sub-clause.