postgresql - 如何启用 PostgreSQL 函数分析器?

标签 postgresql function profiling plpgsql

这花了我一段时间才弄清楚,几周前我在一个外语维基上找到了答案,它非常有帮助,所以我想我会分享。

最佳答案

在 Win32 上的 PostgreSQL 8.3 上,分析插件默认安装,但未加载。只需执行此 SQL:

LOAD '$libdir/plugins/plugin_profiler.dll';
SET plpgsql.profiler_tablename = 'bazzybar';

...然后当你想分析一些代码时,

drop table if exists bazzybar; -- reset the profiling stats
select my_function_here('lala',123);  -- this line and variations as many times as you deem fit
select * from bazzybar; -- show the time spent on each line of your function

关于postgresql - 如何启用 PostgreSQL 函数分析器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/430123/

相关文章:

postgresql - 在 PostgreSQL 中检查组内的条件

sql - 触发更新以更新所有子节点

PHP 为 mysql 交互创建函数还是每次都使用纯代码?

linux - 如何计算进程 ID 的已执行指令数,包括所有 future 的子线程

haskell - 带有崩溃的 Haskell 程序的空 .prof 文件(在 Windows 上)

javascript - 我可以在单页应用程序中使用浏览器 Navigation Timing API 来处理 Ajax 事件吗?如果不是,什么是好的工具?

ruby-on-rails - 查找 first_name 列不以 A-Z 开头的所有记录

java - 如何为每个 INSERT 增加 ID?

python - 无法在 Django 上运行服务器(连接被拒绝)

python - 区分python函数和类函数