How to profile plpgsql function in PostgreSQL 9.2

performance, plpgsql, postgresql, profiling

Solution

PostgreSQL 9.2 has buildin SQL profiler, try to use it - if your plpgsql contains some SQL queries.

http://www.postgresql.org/docs/9.2/static/pgstatstatements.html

and now, plpgsql_check has integrated profiler

Problem

I'd like to find the bottlenecks in a plpgsql function, so I'm looking for a profiler. How do I enable the PostgreSQL function profiler? suggests loading the `plugin_profiler.dll` library, but it was written for 8.3 and there seems to be no such thing in 9.2 I've also installed and the debugger described at http://git.postgresql.org/gitweb/?p=pldebugger.git;a=summary (which is included with 9.2), but can't see any way of using it as a profiler. The simple "RAISE NOTICE" method wouldn't be effective for me, because the function executes in < 0.1 ms, but is called many times.

Original source