From 7e2755a4e21127260e906473b501d2654b79d795 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 27 Sep 2021 14:37:54 +0800 Subject: [PATCH 1/6] add hint LIMIT_TO_COP() --- optimizer-hints.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/optimizer-hints.md b/optimizer-hints.md index cc9b83c5fd9e..933498fb4b29 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -182,6 +182,17 @@ SELECT /*+ IGNORE_INDEX(t1, idx1, idx2) */ * FROM t t1; SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; ``` +### LIMIT_TO_COP() + +`LIMIT_TO_COP()` 提示优化器将制定查询快中的 Limit 和 TopN 算子下推到 coprocessor。如果优化器没有下推 Limit 或者 TopN 算子,建议尝试。例如: + + +{{< copyable "sql" >}} + +```sql +select /*+ LIMIT_TO_COP() */ * from t where a = 1 and b > 10 and b < 20 and c > 50 order by d limit 1 +``` + ### READ_FROM_STORAGE(TIFLASH[t1_name [, tl_name ...]], TIKV[t2_name [, tl_name ...]]) `READ_FROM_STORAGE(TIFLASH[t1_name [, tl_name ...]], TIKV[t2_name [, tl_name ...]])` 提示优化器从指定的存储引擎来读取指定的表,目前支持的存储引擎参数有 `TIKV` 和 `TIFLASH`。如果为表指定了别名,就只能使用表的别名作为 `READ_FROM_STORAGE()` 的参数;如果没有指定别名,则用表的本名作为其参数。例如: From 39c01ca899a7ee2ec85f3d2e61f5609a07970ea6 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 27 Sep 2021 14:40:45 +0800 Subject: [PATCH 2/6] update --- optimizer-hints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index 933498fb4b29..a6ff2f4a2533 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -190,7 +190,7 @@ SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; {{< copyable "sql" >}} ```sql -select /*+ LIMIT_TO_COP() */ * from t where a = 1 and b > 10 and b < 20 and c > 50 order by d limit 1 +SELECT /*+ LIMIT_TO_COP() */ * FROM t WHERE a = 1 AND b > 10 ORDER BY c LIMIT 1; ``` ### READ_FROM_STORAGE(TIFLASH[t1_name [, tl_name ...]], TIKV[t2_name [, tl_name ...]]) From 21e1cddc3b700fe99cc73a0a39d980950856b803 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:12:59 +0800 Subject: [PATCH 3/6] Update optimizer-hints.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 虎 --- optimizer-hints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index a6ff2f4a2533..b7268ceafbae 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -184,7 +184,7 @@ SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; ### LIMIT_TO_COP() -`LIMIT_TO_COP()` 提示优化器将制定查询快中的 Limit 和 TopN 算子下推到 coprocessor。如果优化器没有下推 Limit 或者 TopN 算子,建议尝试。例如: +`LIMIT_TO_COP()` 提示优化器将制定查询块中的 Limit 和 TopN 算子下推到 coprocessor。优化器没有下推 Limit 或者 TopN 算子时建议尝试使用该提示。例如: {{< copyable "sql" >}} From a2ac23240b48cda41e9f8726da6b000d289c5334 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:44:26 +0800 Subject: [PATCH 4/6] Update optimizer-hints.md --- optimizer-hints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index b7268ceafbae..67efc00a3fea 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -184,7 +184,7 @@ SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; ### LIMIT_TO_COP() -`LIMIT_TO_COP()` 提示优化器将制定查询块中的 Limit 和 TopN 算子下推到 coprocessor。优化器没有下推 Limit 或者 TopN 算子时建议尝试使用该提示。例如: +`LIMIT_TO_COP()` 提示优化器将指定查询块中的 `Limit` 和 `TopN` 算子下推到 coprocessor。优化器没有下推 Limit 或者 TopN 算子时建议尝试使用该提示。例如: {{< copyable "sql" >}} From 54dbe21c5ebd3c8b8234d46c12c38b6762d67944 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 27 Sep 2021 16:49:46 +0800 Subject: [PATCH 5/6] Update optimizer-hints.md --- optimizer-hints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index 67efc00a3fea..4296cd78e189 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -184,7 +184,7 @@ SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; ### LIMIT_TO_COP() -`LIMIT_TO_COP()` 提示优化器将指定查询块中的 `Limit` 和 `TopN` 算子下推到 coprocessor。优化器没有下推 Limit 或者 TopN 算子时建议尝试使用该提示。例如: +`LIMIT_TO_COP()` 提示优化器将指定查询块中的 `Limit` 和 `TopN` 算子下推到 coprocessor。优化器没有下推 `Limit` 或者 `TopN` 算子时建议尝试使用该提示。例如: {{< copyable "sql" >}} From 2fd78e7932913f8e592c4586b9696ef831e65648 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 27 Sep 2021 17:34:24 +0800 Subject: [PATCH 6/6] Update optimizer-hints.md --- optimizer-hints.md | 1 - 1 file changed, 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index 4296cd78e189..bc42acbf9cc2 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -186,7 +186,6 @@ SELECT /*+ AGG_TO_COP() */ sum(t1.a) FROM t t1; `LIMIT_TO_COP()` 提示优化器将指定查询块中的 `Limit` 和 `TopN` 算子下推到 coprocessor。优化器没有下推 `Limit` 或者 `TopN` 算子时建议尝试使用该提示。例如: - {{< copyable "sql" >}} ```sql