++ed by:
MISHIN AYOUNG HAARG KARJALA MMCLERIC

75 PAUSE users
46 non-PAUSE users.

Tim Bunce
and 1 contributors

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

Postgres <= 8.4 doesn't execute END blocks when it shuts down, so NYTProf doesn't get a chance to terminate the profile cleanly. To get a usable 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 and I'm working on a patch to fix that and make other improvements to plperl.

Can't use plperl and plperlu at the same time

Postgres uses separate Perl interpreters for the plperl and plperlu languages. NYTProf is not multiplicity safe so if you call functions implemented in the plperl and plperlu languages in the same session, while using NYTProf, you're likely to get garbage or worse.

SEE ALSO

Devel::NYTProf

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.