Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
带占位符的 SQL 执行流程为 prepared -> execute -> close 客户端将该语句和参数发给 mysql 编译成一个 prepared 语句,如果设置
interpolateparams=true
可以减少 prepared 请求,SQL 语句在客户端完成拼接。在go-sql-driver/mysql
库中 如果发现没有设置该参数,会返回一个ErrSkip
被 otelsql 捕捉,可以通过配置DisableErrSkip
忽略这个报错,因为只是优化项不影响后续流程。但有实验表明interpolateparams=true
能提高 QPS 18%,可以考虑在 DSN 中增加该参数https://github.com/go-sql-driver/mysql/blob/f6a18cf1ac3e6bc282f72874a3742469a99e5762/connection.go#L327