Merge pull request #22553 from taosdata/docs/hint
fix: add hints comments
This commit is contained in:
commit
5291209f46
|
@ -9,7 +9,7 @@ description: This document describes how to query data in TDengine.
|
|||
```sql
|
||||
SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW() | TODAY() | TIMEZONE()}
|
||||
|
||||
SELECT [DISTINCT] select_list
|
||||
SELECT [hints] [DISTINCT] select_list
|
||||
from_clause
|
||||
[WHERE condition]
|
||||
[partition_by_clause]
|
||||
|
@ -21,6 +21,11 @@ SELECT [DISTINCT] select_list
|
|||
[LIMIT limit_val [OFFSET offset_val]]
|
||||
[>> export_file]
|
||||
|
||||
hints: /*+ [hint([hint_param_list])] [hint([hint_param_list])] */
|
||||
|
||||
hint:
|
||||
BATCH_SCAN | NO_BATCH_SCAN
|
||||
|
||||
select_list:
|
||||
select_expr [, select_expr] ...
|
||||
|
||||
|
@ -70,6 +75,29 @@ order_expr:
|
|||
{expr | position | c_alias} [DESC | ASC] [NULLS FIRST | NULLS LAST]
|
||||
```
|
||||
|
||||
## Hints
|
||||
|
||||
Hints are a means of user control over query optimization for individual statements. Hints will be ignore automatically if they are not applicable to the current query statement. The specific instructions are as follows:
|
||||
|
||||
- Hints syntax starts with `/*+` and ends with `*/`, spaces are allowed before or after.
|
||||
- Hints syntax can only follow the SELECT keyword.
|
||||
- Each hints can contain multiple hint, separated by spaces. When multiple hints conflict or are identical, whichever comes first takes effect.
|
||||
- When an error occurs with a hint in hints, the effective hint before the error is still valid, and the current and subsequent hints are ignored.
|
||||
- hint_param_list are arguments to each hint, which varies according to each hint.
|
||||
|
||||
The list of currently supported Hints is as follows:
|
||||
|
||||
| **Hint** | **Params** | **Comment** | **Scopt** |
|
||||
| :-----------: | -------------- | -------------------------- | -------------------------- |
|
||||
| BATCH_SCAN | None | Batch table scan | JOIN statment for stable |
|
||||
| NO_BATCH_SCAN | None | Sequential table scan | JOIN statment for stable |
|
||||
|
||||
For example:
|
||||
|
||||
```sql
|
||||
SELECT /*+ BATCH_SCAN() */ a.ts FROM stable1 a, stable2 b where a.tag0 = b.tag0 and a.ts = b.ts;
|
||||
```
|
||||
|
||||
## Lists
|
||||
|
||||
A query can be performed on some or all columns. Data and tag columns can all be included in the SELECT list.
|
||||
|
|
|
@ -9,7 +9,7 @@ description: 查询数据的详细语法
|
|||
```sql
|
||||
SELECT {DATABASE() | CLIENT_VERSION() | SERVER_VERSION() | SERVER_STATUS() | NOW() | TODAY() | TIMEZONE()}
|
||||
|
||||
SELECT [DISTINCT] select_list
|
||||
SELECT [hints] [DISTINCT] select_list
|
||||
from_clause
|
||||
[WHERE condition]
|
||||
[partition_by_clause]
|
||||
|
@ -21,6 +21,11 @@ SELECT [DISTINCT] select_list
|
|||
[LIMIT limit_val [OFFSET offset_val]]
|
||||
[>> export_file]
|
||||
|
||||
hints: /*+ [hint([hint_param_list])] [hint([hint_param_list])] */
|
||||
|
||||
hint:
|
||||
BATCH_SCAN | NO_BATCH_SCAN
|
||||
|
||||
select_list:
|
||||
select_expr [, select_expr] ...
|
||||
|
||||
|
@ -70,6 +75,29 @@ order_expr:
|
|||
{expr | position | c_alias} [DESC | ASC] [NULLS FIRST | NULLS LAST]
|
||||
```
|
||||
|
||||
## Hints
|
||||
|
||||
Hints 是用户控制单个语句查询优化的一种手段,当 Hint 不适用于当前的查询语句时会被自动忽略,具体说明如下:
|
||||
|
||||
- Hints 语法以`/*+`开始,终于`*/`,前后可有空格。
|
||||
- Hints 语法只能跟随在 SELECT 关键字后。
|
||||
- 每个 Hints 可以包含多个 Hint,Hint 间以空格分开,当多个 Hint 冲突或相同时以先出现的为准。
|
||||
- 当 Hints 中某个 Hint 出现错误时,错误出现之前的有效 Hint 仍然有效,当前及之后的 Hint 被忽略。
|
||||
- hint_param_list 是每个 Hint 的参数,根据每个 Hint 的不同而不同。
|
||||
|
||||
目前支持的 Hints 列表如下:
|
||||
|
||||
| **Hint** | **参数** | **说明** | **适用范围** |
|
||||
| :-----------: | -------------- | -------------------------- | -------------------------- |
|
||||
| BATCH_SCAN | 无 | 采用批量读表的方式 | 超级表 JOIN 语句 |
|
||||
| NO_BATCH_SCAN | 无 | 采用顺序读表的方式 | 超级表 JOIN 语句 |
|
||||
|
||||
举例:
|
||||
|
||||
```sql
|
||||
SELECT /*+ BATCH_SCAN() */ a.ts FROM stable1 a, stable2 b where a.tag0 = b.tag0 and a.ts = b.ts;
|
||||
```
|
||||
|
||||
## 列表
|
||||
|
||||
查询语句可以指定部分或全部列作为返回结果。数据列和标签列都可以出现在列表中。
|
||||
|
|
Loading…
Reference in New Issue