NAME
Devel::NYTProf::PgPLPerl - Profile PostgreSQL PL/Perl functions with Devel::NYTProf
SYNOPSIS
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;
DESCRIPTION
This module allows PL/Perl functions inside PostgreSQL database to be profiled with Devel::NYTProf
.
LIMITATIONS
PL/Perl Function Names Are Missing
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.)
Explicit call to finish_profile needed
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
SEE ALSO
AUTHOR
Tim Bunce, http://www.tim.bunce.name and http://blog.timbunce.org
COPYRIGHT AND LICENSE
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.