Thread: Pl/Perl speed

Pl/Perl speed

From
"Chris Ochs"
Date:
I am pretty sure I know this already, but every time you run a Pl/Perl
function it is just like running a perl script as far as having to load and
compile the code right?  My application runs under mod perl so I'm thinking
that speed is not something I would gain by putting any of the code into the
database server via Pl/Perl.

Chris


Re: Pl/Perl speed

From
Tom Lane
Date:
"Chris Ochs" <chris@paymentonline.com> writes:
> I am pretty sure I know this already, but every time you run a Pl/Perl
> function it is just like running a perl script as far as having to load and
> compile the code right?

No, the perl script gets compiled only the first time the function is
invoked (within a given backend session).  Subsequent calls to the
function use the already-compiled function object.  I'm not clear on
exactly how much overhead this saves in Perl, but it's certainly not
as bad as re-loading a script on each call.

I believe all the PL languages have comparable optimizations.

            regards, tom lane

Re: Pl/Perl speed

From
"Joshua D. Drake"
Date:
Chris Ochs wrote:

>I am pretty sure I know this already, but every time you run a Pl/Perl
>function it is just like running a perl script as far as having to load and
>compile the code right?  My application runs under mod perl so I'm thinking
>that speed is not something I would gain by putting any of the code into the
>database server via Pl/Perl.
>
>
You can also preload (if you are running Mammoth or 7.4) the plperl.so
which should
give you a speed increase.

It entirely depends on what you are trying to do with pl/Perl however.
If you need
access to tuple data (ability to modify records etc...) then your kind
of out of luck.
However, if you are using it to perform logic and then spit back the
results pl/Perl
could be very useful and give a speed increase.

The speed increase would come from only returning the results of your
calculation
versus returning a set of data and then performing calculations on that
set and then
displaying it.

Sincerely,

Joshua D. Drake



>Chris
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 7: don't forget to increase your free space map settings
>
>


--
Command Prompt, Inc., home of Mammoth PostgreSQL - S/ODBC and S/JDBC
Postgresql support, programming shared hosting and dedicated hosting.
+1-503-667-4564 - jd@commandprompt.com - http://www.commandprompt.com
Mammoth PostgreSQL Replicator. Integrated Replication for PostgreSQL