加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

postgreSQL解释分析一个函数

发布时间:2020-12-13 18:06:45 所属栏目:百科 来源:网络整理
导读:我试图理解 postgresql中的查询优化,我有一个函数,里面有一些查询.其中一些是简单的查询,它将值保存到变量中,然后下一个查询将此变量用于查找内容..让我们说: function()...select type into tfrom tableAwhere code = a_c;select num into nfrom tableBwhe
我试图理解 postgresql中的查询优化,我有一个函数,里面有一些查询.其中一些是简单的查询,它将值保存到变量中,然后下一个查询将此变量用于查找内容..让我们说:
function()...
select type into t
from tableA
where code = a_c;

select num into n
from tableB
where id = t; 
end function...

还有更多..如果我想解释分析整个函数我执行命令说明解析select function();这是正确的方法吗?或者我应该解释分析函数内的每个查询,如果是这样的话,用什么值?

考虑使用 auto_explain模块:

The auto_explain module provides a means for logging execution plans
of slow statements automatically,without having to run EXPLAIN by
hand. This is especially helpful for tracking down un-optimized
queries in large applications.

打开auto_explain.log_nested_statements:

auto_explain.log_nested_statements (boolean)

auto_explain.log_nested_statements causes nested statements
(statements executed inside a function) to be considered for logging. When it is off,only top-level query plans are logged. This parameter is off by default. Only superusers can change this setting.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读