微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgreSQL解释分析一个函数

我试图理解 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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐