Skip to content

Commit

Permalink
sql: update optimizer hints description
Browse files Browse the repository at this point in the history
  • Loading branch information
lilin90 committed Oct 31, 2018
1 parent a481109 commit f2dd9c7
Showing 1 changed file with 4 additions and 5 deletions.
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

0 comments on commit f2dd9c7

Please sign in to comment.