User-Supplied Hints on Join Equality Conditions

Users can specify a join algorithm preference that does not affect every join in the query.

Simple equality join predicates can be tagged with a predicate hint that allows a join preference to be specified for just that one join. If the same join has more than one join condition with a local join preference, and if those hints are not the same value, then all local preferences are ignored for that join. Local join preferences do not affect the join order chosen by the optimizer.

Example

The following example requests a hash join:
AND (T.X = 10 * R.x, 'J:4')
JOIN_PREFERENCE Values
Value Action
0 Let the optimizer choose
1 Prefer sort-merge
2 Prefer nested-loop
3 Prefer nested-loop push-down
4 Prefer hash
5 Prefer hash push-down
6 Prefer asymmetric sort-merge join
7 Prefer sort-merge push-down
8 Prefer asymmetric sort-merge push-down join
9 Prefer partitioned hash join if the join keys include all the partition keys of a hash partitioned table
10 Prefer partitioned hash-push down join if the join keys include all the partition keys of a hash partitioned table
11 Prefer partitioned sort-merge join if the join keys include all the partition keys of a hash partitioned table
12 Prefer partitioned sort-merge push-down join if the join keys include all the partition keys of a hash partitioned table
-1 Avoid sort-merge
-2 Avoid nested-loop
-3 Avoid nested-loop push-down
-4 Avoid hash
-5 Avoid hash push-down
-6 Avoid asymmetric sort-merge join
-7 Avoid sort-merge push-down
-8 Avoid asymmetric sort-merge push-down join
-9 Avoid partitioned hash join if the join keys include all the partition keys of a hash partitioned table
10 Avoid partitioned hash-push down join if the join keys include all the partition keys of a hash partitioned table
11 Avoid partitioned sort-merge join if the join keys include all the partition keys of a hash partitioned table
12 Avoid partitioned sort-merge push-down join if the join keys include all the partition keys of a hash partitioned table

For more information

Reference: Statements and Options > Database Options > Alphabetical List of Options > JOIN_PREFERENCE Option

Related concepts
User-Supplied Condition Selectivity
User-Supplied Condition Hint Strings
Guidelines for Usage of User-Supplied Condition Hints