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

planner: prepared plan cache support limit #12686

Merged
merged 11 commits into from
Feb 16, 2023
1 change: 0 additions & 1 deletion sql-prepared-plan-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ TiDB 优化器对这两类查询的处理是一样的:`Prepare` 时将参数
- 包含 `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`;
- `?` 在 `Limit` 后的查询,如 `Limit ?` 或者 `Limit 10, ?`,此时 `?` 的具体值对查询性能影响较大,故不缓存;
- `?` 直接在 `Order By` 后的查询,如 `Order By ?`,此时 `?` 表示根据 `Order By` 后第几列排序,排序列不同的查询使用同一个计划可能导致错误结果,故不缓存;如果是普通表达式,如 `Order By a+?` 则会缓存;
- `?` 紧跟在 `Group by` 后的查询,如 `Group By ?`,此时 `?` 表示根据 `Group By` 后第几列聚合,聚合列不同的查询使用同一个计划可能导致错误结果,故不缓存;如果是普通表达式,如 `Group By a+?` 则会缓存;
- `?` 出现在窗口函数 `Window Frame` 定义中的查询,如 `(partition by year order by sale rows ? preceding)`;如果 `?` 出现在窗口函数的其他位置,则会缓存;
Expand Down