Skip to content

Commit

Permalink
planner: update the doc for the leading hint (pingcap#9697)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomShawn authored Aug 5, 2022
1 parent d3bfb02 commit 004464f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion optimizer-hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ The `LEADING` hint does not take effect in the following situations:
+ A duplicated table name is specified in the `LEADING` hint.
+ The optimizer cannot perform join operations according to the order as specified by the `LEADING` hint.
+ The `straight_join()` hint already exists.
+ The query contains an outer join.
+ The query contains an outer join together with the Cartesian product.
+ Any of the `MERGE_JOIN`, `INL_JOIN`, `INL_HASH_JOIN`, and `HASH_JOIN` hints is used at the same time.

In the above situations, a warning is generated.
Expand All @@ -346,6 +346,10 @@ SHOW WARNINGS;
+---------+------+-------------------------------------------------------------------------------------------------------------------+
```

> **Note:**
>
> If the query statement includes an outer join, in the hint you can specify only the tables whose join order can be swapped. If there is a table in the hint whose join order cannot be swapped, the hint will be invalid. For example, in `SELECT * FROM t1 LEFT JOIN (t2 JOIN t3 JOIN t4) ON t1.a = t2.a;`, if you want to control the join order of `t2`, `t3`, and `t4` tables, you cannot specify `t1` in the `LEADING` hint.
### MERGE()

Using the `MERGE()` hint in queries with common table expressions (CTE) can disable the materialization of the subqueries and expand the subquery inlines into CTE. This hint is only applicable to non-recursive CTE. In some scenarios, using `MERGE()` brings higher execution efficiency than the default behavior of allocating a temporary space. For example, pushing down query conditions or in nesting CTE queries:
Expand Down

0 comments on commit 004464f

Please sign in to comment.