Skip to content

使用mysql client时,使用hint不生效 #2951

Answered by PanternBao
PanternBao asked this question in Q&A
Discussion options

You must be logged in to vote

dble中 hint 使用有两种方式:

  1. /*!dble:sql=select 1 from sharding_4_t1*/ sql
  2. /*#dble:sql=select 1 from sharding_4_t1*/ sql

使用第一种方式不会遇到此种情况,而第二种方式可能会不生效。

在这里需要介绍一下mysql clinet登录时的 -c 选项:

-c, --comments
Preserve comments. Send comments to the server.
The default is --skip-comments (discard comments), enable with --comments.

当使用 -c 选项后,mysql client 会保留命令中的注释,否则会吃掉注释,因此/*# hint */ 包裹的hint不会下发到dble中,从而造成了hint失效。

解决方法

在mysql client 中登录时添加-c选项。

Replies: 1 comment 1 reply

Comment options

PanternBao
Nov 10, 2021
Collaborator Author

You must be logged in to vote
1 reply
@yanhuqing666
Comment options

Answer selected by PanternBao
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants