From 004464f43f095a2c534ab1054f7213799afdcf14 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Fri, 5 Aug 2022 17:30:06 +0800 Subject: [PATCH] planner: update the doc for the leading hint (#9697) --- optimizer-hints.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index 633c5a155ed67..809d70182c6cd 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -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. @@ -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: