Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Ran <[email protected]>
  • Loading branch information
Joyinqin and ran-huang authored Mar 26, 2021
1 parent 96df837 commit 5b45ce7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dashboard/dashboard-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ QPS 及 Latency 监控依赖于集群中已正常部署 Prometheus 监控实例

### 概况页面中 Top SQL 语句、最近慢查询显示 `invalid connection` 错误

可能的原因是你开启了 TiDB 的 `prepared-plan-cache` 功能。作为实验性功能,`prepared-plan-cache` 在某些版本的 TiDB 中存在一些缺陷,开启后可能会导致 TiDB Dashboard(及其他应用)出现该问题。可以通过修改 [TiDB 配置文件](/tidb-configuration-file.md#prepared-plan-cache)来关闭 `prepared-plan-cache` 功能。
可能的原因是你开启了 TiDB 的 `prepared-plan-cache` 功能。`prepared-plan-cache` 是实验性功能,在某些版本的 TiDB 中可能无法正常运行,开启后可能会导致 TiDB Dashboard(及其他应用)出现该问题。可以通过修改 [TiDB 配置文件](/tidb-configuration-file.md#prepared-plan-cache)来关闭 `prepared-plan-cache` 功能。
2 changes: 1 addition & 1 deletion sql-prepare-plan-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ key 中任何一项变动(如切换数据库,重命名 `Prepare` 语句,
- 考虑到不同 `Execute` 的参数会不同,执行计划缓存为了保证适配性会禁止一些和具体参数值密切相关的激进查询优化手段,导致对特定的一些参数值,查询计划可能不是最优。比如查询的过滤条件为 `where a > ? and a < ?`,第一次 `Execute` 时参数分别为 2 和 1,考虑到这两个参数下次执行时可能会是 1 和 2,优化器不会生成对当前参数最优的 `TableDual` 执行计划。
- 如果不考虑缓存失效和淘汰,一份执行计划缓存会对应各种不同的参数取值,理论上也会导致某些取值下执行计划非最优。比如查询过滤条件为 `where a < ?`,假如第一次执行 `Execute` 时用的参数值为 1,此时优化器生成最优的 `IndexScan` 执行计划放入缓存,在后续执行 `Exeucte` 时参数变为 10000,此时 `TableScan` 可能才是更优执行计划,但由于执行计划缓存,执行时还是会使用先前生成的 `IndexScan`。因此执行计划缓存更适用于查询较为简单(查询编译耗时占比较高)且执行计划较为固定的业务场景。

目前执行计划缓存功能默认关闭,可以通过打开配置文件中 [`prepare-plan-cache`](/tidb-configuration-file.md#prepared-plan-cache) 启用这项功能。
目前执行计划缓存功能默认关闭,可以通过打开配置文件中 [`prepare-plan-cache`](/tidb-configuration-file.md#prepared-plan-cache)启用这项功能。

> **注意:**
>
Expand Down

0 comments on commit 5b45ce7

Please sign in to comment.