Join-Method Directives
Use join-method directives to influence how tables are joined in the HCL OneDB™-extension joined query.
Element | Description | Restrictions | Syntax |
---|---|---|---|
comments | Text to documents the directive | Must appear between comment symbols | Character string |
Use commas or blank spaces to separate the elements within the parentheses.
The following table describes each of the join-method directives.
- Keyword
- Effect
- USE_NL
- Uses the specified tables as the inner table in a nested-loop
join
If n tables are specified in the FROM clause, then at most (n-1) tables can be specified in the USE_NL join-method directive.
- USE_HASH
- Uses a hash join to access the specified table
You can also choose whether the table will be used to create the hash table or to probe the hash table.
- AVOID_NL
- Does not use the specified table as inner table in a nested loop
join
A table listed with this directive can still participate in a nested loop join as the outer table.
- AVOID_HASH
- Does not access the specified table using a hash join
You can optionally use a hash join, but impose restrictions on the role of the table within the hash join.
A join-method directive takes precedence over the join method forced by the OPTCOMPIND configuration parameter.
- /BUILD
With the USE_HASH directive, this keyword indicates that the specified table be used to construct a hash table. With the AVOID_HASH directive, this keyword indicates that the specified table not be used to construct a hash table.
- /PROBE
With the USE_HASH directive, this keyword indicates that the specified table be used to probe the hash table. With the AVOID_HASH directive, this keyword indicates that the specified table not be used to probe the hash table. You can specify multiple probe tables as long as there is at least one table for which you do not specify PROBE.
For the optimizer to find an efficient join query plan, you must at least run UPDATE STATISTICS LOW for every table that is involved in the join, so as to provide appropriate cost estimates. Otherwise, the optimizer might choose to broadcast the entire table to all instances, even if the table is large.
If neither the /BUILD nor the /PROBE keyword is specified, the optimizer uses cost estimates to determine the role of the table.
SELECT /*+ USE_HASH (dept /BUILD)
The optimizer must use dept to construct a hash table */
name, title, salary, dname
FROM emp, dept, job WHERE loc = 'Phoenix'
AND emp.dno = dept.dno AND emp.job = job.job;
Join-method optimizer directives that you specify for an ANSI-compliant joined query are ignored, but they are listed under Directives Not Followed in the explain output file.