ITPub博客

首页 > 数据库 > 数据库开发技术 > openGauss学习笔记-257 openGauss性能调优-Custom Plan和Generic Plan选择的Hint

openGauss学习笔记-257 openGauss性能调优-Custom Plan和Generic Plan选择的Hint

原创 数据库开发技术 作者:shuchaoyang 时间:2024-01-03 07:00:00 0 删除 编辑

openGauss学习笔记-257 openGauss性能调优-使用Plan Hint进行调优-Custom Plan和Generic Plan选择的Hint257.1 功能描述257.2 语法格式257.3 示例

openGauss学习笔记-257 openGauss性能调优-使用Plan Hint进行调优-Custom Plan和Generic Plan选择的Hint

257.1 功能描述

对于以PBE方式执行的查询语句和DML语句,优化器会基于规则、代价、参数等因素选择生成Custom Plan或Generic Plan执行。用户可以通过use_cplan/use_gplan的hint指定使用哪种计划执行方式。

257.2 语法格式

  • 指定使用Custom Plan:

    use_cplan
  • 指定使用Generic Plan:

    use_gplan

说明:

  • 对于非PBE方式执行的SQL语句,设置本hint不会影响执行方式。

  • 本Hint的优先级仅高于基于代价的选择和plan_cache_mode参数,即plan_cache_mode无法强制选择执行方式的语句本hint也无法生效。

257.3 示例

强制使用Custom Plan

create table t (a int, b int, c int);
prepare p as select /*+ use_cplan */ * from t where a = $1;
explain execute p(1);

计划如下。可以看到过滤条件为入参的实际值,即此计划为Custom Plan。

强制使用Generic Plan

deallocate p;
prepare p as select /*+ use_gplan */ * from t where a = $1;
explain execute p(1);

计划如下。可以看到过滤条件为待填充的入参,即此计划为Generic Plan。


👍 点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!

✏️ 评论,你的意见是我进步的财富!


PS:因为公众号平台更改了推送规则,如果不想错过内容,记得读完点一下“在看”,加个“星标”,这样每次新文章推送才会第一时间出现在你的订阅列表里。点“在看”支持我吧!


原文作者:超哥的IT私房菜;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论
专注于IT系统集成、运维、架构二十年的IT职场老兵,拥有CCNA、OCA、OCP、PGCA、PGCE认证证书,公众号:超哥的IT私房菜,知识星球:超哥的IT私房菜,目前是多家IT厂商的咨询顾问。

注册时间:2021-08-27

  • 博文量
    552
  • 访问量
    303581