From 0df4f8d0452096e7cc28a0fe1a1142f7bdba2e24 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 27 Sep 2021 14:37:54 +0800 Subject: [PATCH 1/5] 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 a4a67f5aca80..65b198cfd9fe 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -183,6 +183,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 a30828ccb9ade7c2465ab0106ef81d70ca148d7c Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 27 Sep 2021 14:40:45 +0800 Subject: [PATCH 2/5] update --- optimizer-hints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optimizer-hints.md b/optimizer-hints.md index 65b198cfd9fe..7452a9cb3682 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -191,7 +191,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 9f11d1712ab6b898f4dc88748b0ce74f0014ffaf 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/5] 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 7452a9cb3682..3f0ba444d9cc 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -185,7 +185,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 5954ca52593c804629efb49b7e58fa1116add766 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/5] 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 3f0ba444d9cc..73783d560583 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -185,7 +185,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 965e304dd8a8bd6c9b2ed7fd8f2ff948f57a13c0 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/5] 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 73783d560583..794e5a0eda02 100644 --- a/optimizer-hints.md +++ b/optimizer-hints.md @@ -185,7 +185,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" >}}