How do I enable the PostgreSQL function profiler?

本小妞迷上赌 提交于 2019-12-03 05:11:37

问题


This took me a while to figure out and I found the answer on a foreign-language wiki a number of weeks ago, and it was very helpful, so I thought I would share.


回答1:


On PostgreSQL 8.3 on Win32, the profiling plugin is installed by default, but not loaded. Just execute this SQL:

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

...and then when you want to profile some code,

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


来源:https://stackoverflow.com/questions/430123/how-do-i-enable-the-postgresql-function-profiler

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!