Devel::NYTProf::PgPLPerl - Profile PostgreSQL PL/Perl functions with Devel::NYTProf
Edit the vars.pm file in the perl installation being used by postgres to add the following lines just below the last subroutine:
# load NYTProf if running inside PostgreSQL require Devel::NYTProf::PgPLPerl if defined &SPI::bootstrap;
This module allows PL/Perl functions inside PostgreSQL database to be profiled with Devel::NYTProf.
Devel::NYTProf
The names of functions defined using CREATE FUNCTION don't show up in NYTProf because they're compiled as anonymous subs using a string eval. There's no easy way to determine the PL/Perl function name because it's only known to the postgres internals.
(There might be a way using DynaLoader::dl_find_symbol(0, "error_context_stack") but I've not had time to dig sufficiently deeply into that yet.)
DynaLoader::dl_find_symbol(0, "error_context_stack")
Currently postgres doesn't execute END blocks when it shuts down, so NYTProf doesn't get a chance to terminate the profile cleanly. To get a useable profile you need to explicitly call finish_profile() in your plperl code.
I've submitted a bug report asking for END blocks to be run at shutdown: http://archives.postgresql.org/pgsql-bugs/2009-09/threads.php#00289
Tim Bunce, http://www.tim.bunce.name and http://blog.timbunce.org
Copyright (C) 2009 by Tim Bunce.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install Devel::NYTProf, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Devel::NYTProf
CPAN shell
perl -MCPAN -e shell install Devel::NYTProf
For more information on module installation, please visit the detailed CPAN module installation guide.