From 5ee1dea8289c4ec061b284b7609fea56f878206d 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 306da24de3af..2855ffdc71a5 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 acaaae09b768a18ad2fb958fac966306bafa689d 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 2855ffdc71a5..4eb7266a1cf2 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 a05f972d83895b5a06b0f925bb61784657d7651a 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 4eb7266a1cf2..449f58934f69 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 3b23a7108bf4f5172e26407f0f4a5db66c125128 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 449f58934f69..20b9cb8bc785 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 3224ef30081e0212c8aa479df3b0e8b1b4abfd6f 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 20b9cb8bc785..d2455bdbf712 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 d4d69279848e0dd0f8ce9a124d4371bc3c152638 Mon Sep 17 00:00:00 2001 From: TomShawn <41534398+TomShawn@users.noreply.github.com> Date: Mon, 27 Sep 2021 17:34:11 +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 d2455bdbf712..cf48ec9f13ad 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