Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimizer-fix-control: add doc for the new optimizer fix controls introduced in v7.3.0 #14535

Merged
merged 11 commits into from
Aug 7, 2023
21 changes: 21 additions & 0 deletions optimizer-fix-controls.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,24 @@ SET SESSION tidb_opt_fix_control = '44262:ON,44389:ON';
- 默认值:`OFF`
- 可选值:`ON`、`OFF`
- 对形如 `c = 10 and (a = 'xx' or (a = 'kk' and b = 1))` 的过滤条件,是否尝试为 `IndexRangeScan` 更加完整地构造扫描范围,即 `range`。

### [`44823`](https://github.com/pingcap/tidb/issues/44823) <span class="version-mark">从 v7.3.0 版本开始引入</span>

- 默认值:`200`
- 可选值:`[0, 2147483647]`
- 为了节省内存,对于参数超过指定个数的查询,Plan Cache 将不会缓存。
- 这个开关用来调节该参数个数的阈值,`0` 表示无限制。
ran-huang marked this conversation as resolved.
Show resolved Hide resolved

### [`44830`](https://github.com/pingcap/tidb/issues/44830) <span class="version-mark">从 v7.3.0 版本开始引入</span>

- 默认值:`OFF`
- 可选值:`ON`、`OFF`
- 此开关控制是否让 Plan Cache 对在物理优化阶段形成的 `PointGet` 计划进行缓存。

### [`44855`](https://github.com/pingcap/tidb/issues/44855) <span class="version-mark">从 v7.3.0 版本开始引入</span>

- 默认值:`OFF`
- 可选值:`ON`、`OFF`
- 在某些场景下,当 `IndexJoin` 算子的 `Probe` 端包含 `Selection` 算子时,TiDB 会严重高估 `IndexScan` 的行数,导致在 `IndexJoin` 更好的时候选择了其它的执行计划。
- TiDB 已经引入了缓解这类问题的逻辑。但是由于潜在的计划回退风险,该逻辑并没有被默认启用。
ran-huang marked this conversation as resolved.
Show resolved Hide resolved
- 此开关控制是否让这个改进生效。
ran-huang marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion sql-non-prepared-plan-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ TiDB 对参数化后形式相同的查询,只能缓存一个计划。例如,
- 不支持 `ORDER BY` 或者 `GROUP BY` 后直接带数字或者表达式的查询,如 `ORDER BY 1`、`GROUP BY a+1`。仅支持 `ORDER BY column_name` 和 `GROUP BY column_name`。
- 不支持过滤条件中包含 `JSON`、`ENUM`、`SET` 或 `BIT` 类型的列的查询,例如 `SELECT * FROM t WHERE json_col = '{}'`。
- 不支持过滤条件中出现 `NULL` 值的查询,例如 `SELECT * FROM t WHERE a is NULL`。
- 不支持参数化后参数个数超过 200 个的查询,例如 `SELECT * FROM t WHERE a in (1, 2, 3, ... 201)`。
- 默认不支持参数化后参数个数超过 200 个的查询,例如 `SELECT * FROM t WHERE a in (1, 2, 3, ... 201)`。从 v7.3.0 开始,你可以通过 [`tidb_opt_fix_control`](/system-variables.md#tidb_opt_fix_control-从-v710-版本开始引入) 系统变量来调整该限制
time-and-fate marked this conversation as resolved.
Show resolved Hide resolved
- 不支持访问分区表、虚拟列、临时表、视图、或内存表的查询,例如 `SELECT * FROM INFORMATION_SCHEMA.COLUMNS`,其中 `COLUMNS` 为 TiDB 内存表。
- 不支持带有 Hint 或有 Binding 的查询。
- 默认不支持 DML 语句或包含 `FOR UPDATE` 的查询语句。若要启用支持,你可以执行 `SET tidb_enable_non_prepared_plan_cache_for_dml = ON`。
Expand Down