From 49472f99648a315d00609c68f3256119f660ecf4 Mon Sep 17 00:00:00 2001 From: Yuanjia Zhang Date: Mon, 27 Sep 2021 17:20:57 +0800 Subject: [PATCH] Add the hint LIMIT_TO_COP() (#7202) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add hint LIMIT_TO_COP() * update * Update optimizer-hints.md Co-authored-by: 虎 * Update optimizer-hints.md * Update optimizer-hints.md Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com> Co-authored-by: 虎 --- optimizer-hints.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/optimizer-hints.md b/optimizer-hints.md index a4a67f5aca80..794e5a0eda02 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 ORDER BY c 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()` 的参数;如果没有指定别名,则用表的本名作为其参数。例如: