SlideShare a Scribd company logo
PL/Perl New Features
    in PostgreSQL 9.0


     Tim Bunce - June 2010
     Creative Commons BY-NC-SA 3.0
PL/Perl Changes

   ‣ USER
   ‣ INTERNAL
   ‣ DBA
   ‣ NYTPROF
PL/Perl Changes

   ‣ USER
   ‣ INTERNAL
   ‣ DBA
   ‣ NYTPROF
New Builtins
quote_...

 quote_literal( "foo"            ) ==> "'foo'"
 quote_literal( "don't "carp"" ) ==> "'don''t "carp"'"
 quote_literal( ""               ) ==> "''"


quote_nullable( "foo"            ) ==> "'foo'"
quote_nullable( "don't "carp"" ) ==> "'don''t "carp"'"
quote_nullable( ""               ) ==> "''"


quote_ident( "foo"            ) ==> "foo"
quote_ident( "don't "carp"" ) ==> ""don't ""carp""""
quote_ident( ""               ) ==> """"
quote_...(undef)


 quote_literal( undef   ) ==> undef


quote_nullable( undef   ) ==> "NULL"


   quote_ident( undef   ) ==> """"   (warn)
{en,de}code_bytea
encode_bytea( "foo"            ) ==> "x666f6f"
decode_bytea( "x666f6f"      ) ==> "foo"
decode_bytea( "146157157") ==> "foo"


encode_bytea( "x{263a}"       ) ==> "xe298ba"         UTF8
decode_bytea( "xe298ba"      ) ==> "342230272"      Not UTF8


encode_bytea( ""               ) ==> "x"
decode_bytea( "x"            ) ==> ""
decode_bytea( ""               ) ==> ""


encode_bytea( undef            ) ==> "x"      (warn)
decode_bytea( undef            ) ==> ""      (warn)
looks_like_number

looks_like_number( 1           ) ==> 1
looks_like_number( 0           ) ==> 1
looks_like_number( "+7.2e-9"   ) ==> 1


looks_like_number( "foo"       ) ==> 0
looks_like_number( ""          ) ==> 0
looks_like_number( undef       ) ==> undef


looks_like_number( " 4 "       ) ==> 1


looks_like_number( "5plus"     ) ==> 0   (but '5plus'+0=5)
encode_array_*

encode_array_literal( ["foo","bar"] )
   ==> "{"foo", "bar"}"


encode_array_constructor( ["foo","bar"] )
   ==> "ARRAY['foo', 'bar']"



encode_array_literal( [1,[2,[undef]]]   )
   ==> "{"1", {"2", {NULL}}}"


encode_array_constructor( [1,[2,[undef]]]   )
   ==> "ARRAY['1', ARRAY['2', ARRAY[NULL]]]"
encode_array_*


encode_array_literal(       "foo"   ) ==> "foo"
encode_array_constructor(   "foo"   ) ==> "'foo'"


encode_array_literal(       undef   ) ==> undef
encode_array_constructor(   undef   ) ==> "NULL"
Trusted require/use
• require/use work for already loaded modules
use strict;            # old way: BEGIN { strict->import(); }



• extra pre-loaded modules
use warnings;
use Carp;
use feature qw(say);   # for perl 5.10 or later
use utf8;              # if server_encoding is utf8
CONTEXT: ...

• PL/Perl tracks the context of log messages
  - before:
    WARNING: ...some warning from perl code...


  - now:
    WARNING: ...some warning from perl code...
    CONTEXT: PL/Perl function "..."
DO '...' LANGUAGE plperl;

• Arbitrary chunks of perl code can be executed
    directly from psql, or client apps, via DO
•   No need to create and run a stored procedure
    each time.

    DO $$
        spi_exec("... $_ ...") for 'a'..'z';
    $$ language plperl;
Other Changes
• Using $a and $b in sort blocks now works!
• eval { ... } and eval "..."
  - can now be used in plperl
• END blocks are now run at end of session
  - they can't (currently) access the database
• Warnings from perl are now WARNINGs
  - they used to be NOTICE
PL/Perl Changes

   ‣ USER
   ‣ INTERNAL
   ‣ DBA
   ‣ NYTPROF
INTERNAL

• The Safe module is no longer used for plperl
  - Improved security and reduced call overheads
  - Upgrade to latest security patch!
• Validates return values are in server encoding
  - ERROR: invalid byte sequence for encoding
• Internal code refactoring and cleanup
PL/Perl Changes

   ‣ USER
   ‣ INTERNAL
   ‣ DBA
   ‣ NYTPROF
New plperl.* Config
• Specify perl code to run during initialization:

  plperl.on_init            = '...perl...'
  plperl.on_plperlu_init = '...perl...'
  plperl.on_plperl_init     = '...perl...'


• Can only be set by superuser or postgres.conf
• Code can't access the database
~ Timeline ~
▾   Perl interpreter created on demand
    ▿ Options from PERL5OPT env var are processed
    ▿ PL/Perl support code bootstraps
    ▿ plperl.on_init code runs
      Above may happen in postmaster at startup if
      plperl is loaded via shared_preload_libraries
▾ Interpreter is specialised for plperl (or plperlu)
    ▿ Modules loaded: strict, warnings, features, Carp
    ▿ Perl operators are restricted (require, open etc.)
    ▿ DynaLoader package is deleted
    ▿ plperl.on_plperl_init code runs
    ▿ Database access is enabled
plperl.on_init

• Handy to set global perl configuation
  plperl.on_init='use lib qw(/myapp); use ...;'
  plperl.on_init='require "plperloninit.pl";'


• SECURITY RISK!
  Only load modules you're happy for plperl code to use!
  Also check any other modules loaded as dependencies!
  Use Devel::TraceLoad to see what's actually loaded:
  PERL5OPT='-MDevel::Trace=summary' pg_ctl ...
PL/Perl Best Practice

•   Include explicit use statements in functions
•   Don't assume modules have been pre-loaded
•   For plperlu that'll actually load if needed
•   For plperl it'll check that module was loaded
    - so you'll get an immediate clear failure if not
    - for example on a replica with old postgres.conf file
plperl.on_plperl_init

• Originally intended for things like
  -   PGOPTIONS="-c plperl.on_plperl_init='...'"

  - to enable debug or profiling for a session
• But...
• Can only be set by superuser or postgres.conf
  - sadly, due to SECURITY DEFINER risks.
  - You shouldn't write SECURITY DEFINER
    functions in plperl if untrusted users can use plperl!
PL/Perl Changes

   ‣ USER
   ‣ INTERNAL
   ‣ DBA
   ‣ NYTPROF
Devel::NYTProf
Perl Source Code Profiler


PostgreSQL::PLPerl::NYTProf
Enabling NYTProf
• Via postgres.conf:
  plperl.on_init='use PostgreSQL::PLPerl::NYTProf'



• Via environment variable:
  PERL5OPT='-MPostgreSQL::PLPerl::NYTProf' pg_ctl ...



• Immediately active. To enable on demand:
  NYTPROF=start=no PERL5OPT=... pg_ctl ...
  DO 'DB::enable_profile' LANGUAGE plperl;
Reporting from NYTProf

• Writes per-backend data files:
  $PGDATA/nytprof.out.$pid



• To generate a report:
  nytprofhtml --file=$PGDATA/nytprof.out.4321 --open
~ Demo ~
                Screencast: http://timbunce.blip.tv
Video: http://www.fosslc.org/drupal/content/plperl-new-features-90
Questions?

Tim.Bunce@pobox.com
http://blog.timbunce.org
 @timbunce on twitter
http://xkcd.com/519/

More Related Content

What's hot (20)

PPT
On UnQLite
charsbar
 
PDF
RestMQ - HTTP/Redis based Message Queue
Gleicon Moraes
 
PDF
Bottom to Top Stack Optimization - CICON2011
CodeIgniter Conference
 
ODP
Php in 2013 (Web-5 2013 conference)
julien pauli
 
PPT
typemap in Perl/XS
charsbar
 
PDF
Redis as a message queue
Brandon Lamb
 
ZIP
AnyMQ, Hippie, and the real-time web
clkao
 
PDF
What you need to remember when you upload to CPAN
charsbar
 
PDF
High Performance tDiary
Hiroshi SHIBATA
 
PDF
Profiling php5 to php7
julien pauli
 
PDF
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
PDF
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
PDF
Devinsampa nginx-scripting
Tony Fabeen
 
PDF
Memory Manglement in Raku
Workhorse Computing
 
PDF
Using ngx_lua in UPYUN
Cong Zhang
 
PDF
Doing It Wrong with Puppet -
Puppet
 
PDF
Understanding PHP objects
julien pauli
 
PDF
Redis & ZeroMQ: How to scale your application
rjsmelo
 
ODP
PHP5.5 is Here
julien pauli
 
PDF
Lightweight wrapper for Hive on Amazon EMR
Shinji Tanaka
 
On UnQLite
charsbar
 
RestMQ - HTTP/Redis based Message Queue
Gleicon Moraes
 
Bottom to Top Stack Optimization - CICON2011
CodeIgniter Conference
 
Php in 2013 (Web-5 2013 conference)
julien pauli
 
typemap in Perl/XS
charsbar
 
Redis as a message queue
Brandon Lamb
 
AnyMQ, Hippie, and the real-time web
clkao
 
What you need to remember when you upload to CPAN
charsbar
 
High Performance tDiary
Hiroshi SHIBATA
 
Profiling php5 to php7
julien pauli
 
How to Develop Puppet Modules: From Source to the Forge With Zero Clicks
Carlos Sanchez
 
Mysqlnd, an unknown powerful PHP extension
julien pauli
 
Devinsampa nginx-scripting
Tony Fabeen
 
Memory Manglement in Raku
Workhorse Computing
 
Using ngx_lua in UPYUN
Cong Zhang
 
Doing It Wrong with Puppet -
Puppet
 
Understanding PHP objects
julien pauli
 
Redis & ZeroMQ: How to scale your application
rjsmelo
 
PHP5.5 is Here
julien pauli
 
Lightweight wrapper for Hive on Amazon EMR
Shinji Tanaka
 

Similar to PL/Perl - New Features in PostgreSQL 9.0 (20)

KEY
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
PPTX
Perl basics for Pentesters
Sanjeev Kumar Jaiswal
 
ODP
Perl - laziness, impatience, hubris, and one liners
Kirk Kimmel
 
KEY
SPL, not a bridge too far
Michelangelo van Dam
 
ODP
Perl one-liners
daoswald
 
KEY
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
PDF
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
CODE BLUE
 
PDF
Good Evils In Perl
Kang-min Liu
 
PDF
Performance Profiling in Rust
InfluxData
 
PDF
Barely Legal Xxx Perl Presentation
Attila Balazs
 
PDF
Internationalizing CakePHP Applications
Pierre MARTIN
 
ODP
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar
 
PPTX
Learning Puppet basic thing
DaeHyung Lee
 
PDF
Apache Hadoop Shell Rewrite
Allen Wittenauer
 
PDF
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
ConFoo
 
PDF
Puppet @ Seat
Alessandro Franceschi
 
PDF
Os Treat
oscon2007
 
ODP
Perl Moderno
Tiago Peczenyj
 
ODP
What's new in Perl 5.10?
acme
 
Yapcasia2011 - Hello Embed Perl
Hideaki Ohno
 
Perl basics for Pentesters
Sanjeev Kumar Jaiswal
 
Perl - laziness, impatience, hubris, and one liners
Kirk Kimmel
 
SPL, not a bridge too far
Michelangelo van Dam
 
Perl one-liners
daoswald
 
Good Evils In Perl (Yapc Asia)
Kang-min Liu
 
various tricks for remote linux exploits  by Seok-Ha Lee (wh1ant)
CODE BLUE
 
Good Evils In Perl
Kang-min Liu
 
Performance Profiling in Rust
InfluxData
 
Barely Legal Xxx Perl Presentation
Attila Balazs
 
Internationalizing CakePHP Applications
Pierre MARTIN
 
Integrating icinga2 and the HashiCorp suite
Bram Vogelaar
 
Learning Puppet basic thing
DaeHyung Lee
 
Apache Hadoop Shell Rewrite
Allen Wittenauer
 
Marrow: A Meta-Framework for Python 2.6+ and 3.1+
ConFoo
 
Puppet @ Seat
Alessandro Franceschi
 
Os Treat
oscon2007
 
Perl Moderno
Tiago Peczenyj
 
What's new in Perl 5.10?
acme
 
Ad

More from Tim Bunce (12)

PDF
Devel::NYTProf v5 at YAPC::NA 201406
Tim Bunce
 
PDF
Perl Memory Use 201207 (OUTDATED, see 201209 )
Tim Bunce
 
PDF
Perl Dist::Surveyor 2011
Tim Bunce
 
PDF
Perl6 DBDI YAPC::EU 201008
Tim Bunce
 
KEY
Perl 6 DBDI 201007 (OUTDATED, see 201008)
Tim Bunce
 
PDF
DBI Advanced Tutorial 2007
Tim Bunce
 
PDF
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Tim Bunce
 
PDF
Perl Myths 200909
Tim Bunce
 
KEY
DashProfiler 200807
Tim Bunce
 
PDF
DBI for Parrot and Perl 6 Lightning Talk 2007
Tim Bunce
 
PDF
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Tim Bunce
 
PDF
Perl Myths 200802 with notes (OUTDATED, see 200909)
Tim Bunce
 
Devel::NYTProf v5 at YAPC::NA 201406
Tim Bunce
 
Perl Memory Use 201207 (OUTDATED, see 201209 )
Tim Bunce
 
Perl Dist::Surveyor 2011
Tim Bunce
 
Perl6 DBDI YAPC::EU 201008
Tim Bunce
 
Perl 6 DBDI 201007 (OUTDATED, see 201008)
Tim Bunce
 
DBI Advanced Tutorial 2007
Tim Bunce
 
Devel::NYTProf v3 - 200908 (OUTDATED, see 201008)
Tim Bunce
 
Perl Myths 200909
Tim Bunce
 
DashProfiler 200807
Tim Bunce
 
DBI for Parrot and Perl 6 Lightning Talk 2007
Tim Bunce
 
Devel::NYTProf 2009-07 (OUTDATED, see 201008)
Tim Bunce
 
Perl Myths 200802 with notes (OUTDATED, see 200909)
Tim Bunce
 
Ad

Recently uploaded (20)

PDF
July Patch Tuesday
Ivanti
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
July Patch Tuesday
Ivanti
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
HubSpot Main Hub: A Unified Growth Platform
Jaswinder Singh
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Biography of Daniel Podor.pdf
Daniel Podor
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 

PL/Perl - New Features in PostgreSQL 9.0

  • 1. PL/Perl New Features in PostgreSQL 9.0 Tim Bunce - June 2010 Creative Commons BY-NC-SA 3.0
  • 2. PL/Perl Changes ‣ USER ‣ INTERNAL ‣ DBA ‣ NYTPROF
  • 3. PL/Perl Changes ‣ USER ‣ INTERNAL ‣ DBA ‣ NYTPROF
  • 5. quote_... quote_literal( "foo" ) ==> "'foo'" quote_literal( "don't "carp"" ) ==> "'don''t "carp"'" quote_literal( "" ) ==> "''" quote_nullable( "foo" ) ==> "'foo'" quote_nullable( "don't "carp"" ) ==> "'don''t "carp"'" quote_nullable( "" ) ==> "''" quote_ident( "foo" ) ==> "foo" quote_ident( "don't "carp"" ) ==> ""don't ""carp"""" quote_ident( "" ) ==> """"
  • 6. quote_...(undef) quote_literal( undef ) ==> undef quote_nullable( undef ) ==> "NULL" quote_ident( undef ) ==> """" (warn)
  • 7. {en,de}code_bytea encode_bytea( "foo" ) ==> "x666f6f" decode_bytea( "x666f6f" ) ==> "foo" decode_bytea( "146157157") ==> "foo" encode_bytea( "x{263a}" ) ==> "xe298ba" UTF8 decode_bytea( "xe298ba" ) ==> "342230272" Not UTF8 encode_bytea( "" ) ==> "x" decode_bytea( "x" ) ==> "" decode_bytea( "" ) ==> "" encode_bytea( undef ) ==> "x" (warn) decode_bytea( undef ) ==> "" (warn)
  • 8. looks_like_number looks_like_number( 1 ) ==> 1 looks_like_number( 0 ) ==> 1 looks_like_number( "+7.2e-9" ) ==> 1 looks_like_number( "foo" ) ==> 0 looks_like_number( "" ) ==> 0 looks_like_number( undef ) ==> undef looks_like_number( " 4 " ) ==> 1 looks_like_number( "5plus" ) ==> 0 (but '5plus'+0=5)
  • 9. encode_array_* encode_array_literal( ["foo","bar"] ) ==> "{"foo", "bar"}" encode_array_constructor( ["foo","bar"] ) ==> "ARRAY['foo', 'bar']" encode_array_literal( [1,[2,[undef]]] ) ==> "{"1", {"2", {NULL}}}" encode_array_constructor( [1,[2,[undef]]] ) ==> "ARRAY['1', ARRAY['2', ARRAY[NULL]]]"
  • 10. encode_array_* encode_array_literal( "foo" ) ==> "foo" encode_array_constructor( "foo" ) ==> "'foo'" encode_array_literal( undef ) ==> undef encode_array_constructor( undef ) ==> "NULL"
  • 11. Trusted require/use • require/use work for already loaded modules use strict; # old way: BEGIN { strict->import(); } • extra pre-loaded modules use warnings; use Carp; use feature qw(say); # for perl 5.10 or later use utf8; # if server_encoding is utf8
  • 12. CONTEXT: ... • PL/Perl tracks the context of log messages - before: WARNING: ...some warning from perl code... - now: WARNING: ...some warning from perl code... CONTEXT: PL/Perl function "..."
  • 13. DO '...' LANGUAGE plperl; • Arbitrary chunks of perl code can be executed directly from psql, or client apps, via DO • No need to create and run a stored procedure each time. DO $$ spi_exec("... $_ ...") for 'a'..'z'; $$ language plperl;
  • 14. Other Changes • Using $a and $b in sort blocks now works! • eval { ... } and eval "..." - can now be used in plperl • END blocks are now run at end of session - they can't (currently) access the database • Warnings from perl are now WARNINGs - they used to be NOTICE
  • 15. PL/Perl Changes ‣ USER ‣ INTERNAL ‣ DBA ‣ NYTPROF
  • 16. INTERNAL • The Safe module is no longer used for plperl - Improved security and reduced call overheads - Upgrade to latest security patch! • Validates return values are in server encoding - ERROR: invalid byte sequence for encoding • Internal code refactoring and cleanup
  • 17. PL/Perl Changes ‣ USER ‣ INTERNAL ‣ DBA ‣ NYTPROF
  • 18. New plperl.* Config • Specify perl code to run during initialization: plperl.on_init = '...perl...' plperl.on_plperlu_init = '...perl...' plperl.on_plperl_init = '...perl...' • Can only be set by superuser or postgres.conf • Code can't access the database
  • 19. ~ Timeline ~ ▾ Perl interpreter created on demand ▿ Options from PERL5OPT env var are processed ▿ PL/Perl support code bootstraps ▿ plperl.on_init code runs Above may happen in postmaster at startup if plperl is loaded via shared_preload_libraries ▾ Interpreter is specialised for plperl (or plperlu) ▿ Modules loaded: strict, warnings, features, Carp ▿ Perl operators are restricted (require, open etc.) ▿ DynaLoader package is deleted ▿ plperl.on_plperl_init code runs ▿ Database access is enabled
  • 20. plperl.on_init • Handy to set global perl configuation plperl.on_init='use lib qw(/myapp); use ...;' plperl.on_init='require "plperloninit.pl";' • SECURITY RISK! Only load modules you're happy for plperl code to use! Also check any other modules loaded as dependencies! Use Devel::TraceLoad to see what's actually loaded: PERL5OPT='-MDevel::Trace=summary' pg_ctl ...
  • 21. PL/Perl Best Practice • Include explicit use statements in functions • Don't assume modules have been pre-loaded • For plperlu that'll actually load if needed • For plperl it'll check that module was loaded - so you'll get an immediate clear failure if not - for example on a replica with old postgres.conf file
  • 22. plperl.on_plperl_init • Originally intended for things like - PGOPTIONS="-c plperl.on_plperl_init='...'" - to enable debug or profiling for a session • But... • Can only be set by superuser or postgres.conf - sadly, due to SECURITY DEFINER risks. - You shouldn't write SECURITY DEFINER functions in plperl if untrusted users can use plperl!
  • 23. PL/Perl Changes ‣ USER ‣ INTERNAL ‣ DBA ‣ NYTPROF
  • 24. Devel::NYTProf Perl Source Code Profiler PostgreSQL::PLPerl::NYTProf
  • 25. Enabling NYTProf • Via postgres.conf: plperl.on_init='use PostgreSQL::PLPerl::NYTProf' • Via environment variable: PERL5OPT='-MPostgreSQL::PLPerl::NYTProf' pg_ctl ... • Immediately active. To enable on demand: NYTPROF=start=no PERL5OPT=... pg_ctl ... DO 'DB::enable_profile' LANGUAGE plperl;
  • 26. Reporting from NYTProf • Writes per-backend data files: $PGDATA/nytprof.out.$pid • To generate a report: nytprofhtml --file=$PGDATA/nytprof.out.4321 --open
  • 27. ~ Demo ~ Screencast: http://timbunce.blip.tv Video: http://www.fosslc.org/drupal/content/plperl-new-features-90