Skip to content

Commit

Permalink
sql: remove warning for issue 51407 in plan cache (#17232)
Browse files Browse the repository at this point in the history
  • Loading branch information
songrijie authored May 13, 2024
1 parent 74a7d9f commit fbf081a
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions sql-prepared-plan-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ summary: Prepare 语句执行计划缓存功能默认打开,可通过变量启

# Prepare 语句执行计划缓存

> **警告:**
>
> 如果已经被缓存的 `UPDATE``DELETE` 语句在执行过程中,同时遇到 DDL 对相关 schema 进行变更,可能会导致表和索引的数据不一致。详情参考 [Issue #51407](https://github.com/pingcap/tidb/issues/51407)。请关注该 Issue 的修复状态,并升级到[最新的 LTS 版本](https://docs.pingcap.com/zh/tidb/stable)解决该问题。在升级前,你可以尝试以下规避方法:
>
> - 在执行 DDL 前,暂时[关闭 Prepare 语句的执行计划缓存](/system-variables.md#tidb_enable_prepared_plan_cache-从-v610-版本开始引入),DDL 执行完毕后再恢复打开。
> - 避免在业务高峰期执行 DDL。执行 DDL 后立即运行 [`ADMIN CHECK TABLE`](/sql-statements/sql-statement-admin-check-table-index.md) 检查表和索引的一致性,一旦发现错误则重建相关索引。
TiDB 支持对 `Prepare`/`Execute` 请求的执行计划缓存。其中包括以下两种形式的预处理语句:

- 使用 `COM_STMT_PREPARE``COM_STMT_EXECUTE` 的协议功能;
Expand Down Expand Up @@ -71,7 +64,7 @@ key 中任何一项变动(如切换数据库、重命名 `Prepare` 语句、

> **注意:**
>
> 执行计划缓存功能仅针对 `Prepare`/`Execute` 请求,对普通查询无效。
> 系统变量 [`tidb_enable_prepared_plan_cache`](/system-variables.md#tidb_enable_prepared_plan_cache-从-v610-版本开始引入) 控制的执行计划缓存仅针对 `Prepare`/`Execute` 请求,对普通查询无效。普通查询的执行计划缓存参见[非 Prepare 语句执行计划缓存](/sql-non-prepared-plan-cache.md)
在开启了执行计划缓存功能后,可以通过 SESSION 级别的系统变量 [`last_plan_from_cache`](/system-variables.md#last_plan_from_cache-从-v40-版本开始引入) 查看上一条 `Execute` 语句是否使用了缓存的执行计划,例如:

Expand Down

0 comments on commit fbf081a

Please sign in to comment.