Skip to content

Commit

Permalink
planner: plan cache support subquery (#13228)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzzf678 authored Mar 20, 2023
1 parent b40f23d commit 37d4562
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sql-prepared-plan-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ TiDB 优化器对这两类查询的处理是一样的:`Prepare` 时将参数

- `SELECT``UPDATE``INSERT``DELETE``Union``Intersect``Except` 以外的 SQL 语句;
- 访问分区表、临时表或访问表中包含生成列的查询;
- 包含子查询的查询,如 `select * from t where a > (select ...)`
- 查询中包含非关联子查询,例如 `SELECT * FROM t1 WHERE t1.a > (SELECT 1 FROM t2 WHERE t2.b < 1)`
- 执行计划中带有 `PhysicalApply` 算子的关联子查询,例如 `SELECT * FROM t1 WHERE t1.a > (SELECT a FROM t2 WHERE t1.b > t2.b)`
- 包含 `ignore_plan_cache` 这一 Hint 的查询,例如 `select /*+ ignore_plan_cache() */ * from t`
- 包含除 `?` 外其他变量(即系统变量或用户自定义变量)的查询,例如 `select * from t where a>? and b>@x`
- 查询包含无法被缓存函数。目前不能被缓存的函数有:`database()``current_user``current_role``user``connection_id``last_insert_id``row_count``version``like`
Expand Down
8 changes: 8 additions & 0 deletions system-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -1527,6 +1527,14 @@ MPP 是 TiFlash 引擎提供的分布式计算框架,允许节点之间的数
- 默认值:`ON`
- 这个变量用来控制 Prepared Plan Cache 是否缓存 `LIMIT` 后面带变量 (`LIMIT ?`) 的执行计划。目前不支持缓存 `LIMIT` 后面带变量且变量值大于 10000 的执行计划。
### `tidb_enable_plan_cache_for_subquery` <span class="version-mark">从 v7.0.0 版本开始引入</span>
- 作用域:SESSION | GLOBAL
- 是否持久化到集群:是
- 类型:布尔型
- 默认值:`ON`
- 这个变量用来控制 Prepared Plan Cache 是否缓存包含子查询的查询。
### `tidb_enable_plan_replayer_capture`
- 作用域:SESSION | GLOBAL
Expand Down

0 comments on commit 37d4562

Please sign in to comment.