PL/pgSQL benchmarking

PostgreSQL 8.4 added a feature to allow track statistics on how long each database function written in PL/pgSQL and similar languages takes to execute. To enable this, edit your postgresql conf:

track_functions = all  

The other option here is pl, which only tracks the pl/* language functions instead of all of them (that is, not the ones written in C). Once that's done, you've executed some functions, and you've waited a moment for those to show up in the statistics collector, the following query will show you what executed:

SELECT * FROM pg_stat_user_functions;

In earlier versions, it was possible to build your own test harness. If instead you'd like to figure out which individual statements are responsible for the overhead, ...

Get PostgreSQL 10 High Performance now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.