Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: update optimizer hints description #967

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions sql/tidb-specific.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ category: compatibility

TiDB 在 MySQL 的基础上,定义了一些专用的系统变量和语法用来优化性能。

## System Variable
## 系统变量

变量可以通过 SET 语句设置,例如

Expand Down Expand Up @@ -363,12 +363,11 @@ set @@global.tidb_distsql_scan_concurrency = 10

可设置为 `NO_PRIORITY`、`LOW_PRIORITY`、`DELAYED` 或 `HIGH_PRIORITY`。

## Optimizer Hint
## Optimizer Hints

TiDB 在 MySQL 的 Optimizer Hint 语法上,增加了一些 TiDB 专有的 Hint 语法, 使用这些 Hint 的时候,TiDB 优化器会尽量使用指定的算法,在某些场景下会比默认算法更优
TiDB 支持 Optimizer Hints 语法,它基于 MySQL 5.7 中介绍的类似 comment 的语法,例如 `/*+ TIDB_XX(t1, t2) */`。当 TiDB 优化器选择的不是最优查询计划时,建议使用 Optimizer Hints

由于 hint 包含在类似 `/*+ xxx */` 的 comment 里,MySQL 客户端在 5.7.7 之前,会默认把 comment 清除掉,如果需要在旧的客户端使用 hint,需要在启动客户端时加上
`--comments` 选项,例如 `mysql -h 127.0.0.1 -P 4000 -uroot --comments`
> **注意**:MySQL 命令行客户端在 5.7.7 版本之前默认清除了 Optimizer Hints。如果需要在这些早期版本的客户端中使用 `Hint` 语法,需要在启动客户端时加上 `--comments` 选项,例如 `mysql -h 127.0.0.1 -P 4000 -uroot --comments`。

### TIDB_SMJ(t1, t2)

Expand Down