Unix Technical Forum

pl/* overhead ...

This is a discussion on pl/* overhead ... within the pgsql Sql forums, part of the PostgreSQL category; --> Does anyone know of, or have, any comparisions of the overhead going with something like pl/perl or pl/php vs ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Sql

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 12:52 PM
Marc G. Fournier
 
Posts: n/a
Default pl/* overhead ...


Does anyone know of, or have, any comparisions of the overhead going with
something like pl/perl or pl/php vs using pl/pgsql?

Thanks ...

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 12:52 PM
Michael Fuhr
 
Posts: n/a
Default Re: pl/* overhead ...

On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote:
> Does anyone know of, or have, any comparisions of the overhead going with
> something like pl/perl or pl/php vs using pl/pgsql?


Benchmark results will probably depend on the type of processing
you're doing. I'd expect PL/pgSQL to be faster at database operations
like looping through query results, and other languages to be faster
at non-database operations like text munging and number crunching,
depending on the particular language's strengths.

[Does quick test.]

Whale oil beef hooked. PL/pgSQL just outran PL/Perl when I expected
the latter to win. Hang on, let me play with it until it comes back
with the results I want....

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 12:52 PM
Marc G. Fournier
 
Posts: n/a
Default Re: pl/* overhead ...

On Wed, 26 Oct 2005, Michael Fuhr wrote:

> On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote:
>> Does anyone know of, or have, any comparisions of the overhead going with
>> something like pl/perl or pl/php vs using pl/pgsql?

>
> Benchmark results will probably depend on the type of processing
> you're doing. I'd expect PL/pgSQL to be faster at database operations
> like looping through query results, and other languages to be faster
> at non-database operations like text munging and number crunching,
> depending on the particular language's strengths.
>
> [Does quick test.]
>
> Whale oil beef hooked. PL/pgSQL just outran PL/Perl when I expected
> the latter to win. Hang on, let me play with it until it comes back
> with the results I want....


'k, let's repharase the questions

Overall, I'd expect pl/pgsql to have less overhead, since its "built into"
the server ... in the case of something like pl/php or pl/perl, assuming
that I don't use any external modules, is it just as 'built in', or am I
effectively calling an external interpreter each time I run that function?

For instance, if there wasn't something like to_char() (thanks for
pointing that one out), then i could write a simple pl/perl function that
'simulated it', but itself did no db queries just a simple:

RETURN sprintf("%04d", intval);

Don't know if that made much more sense ... ?


----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 12:53 PM
Jan Wieck
 
Posts: n/a
Default Re: pl/* overhead ...

PL/pgSQL is as *internal* as for example PL/Tcl. The two are actually
pretty similar and I would expect them to perform similar, if one knows
what and how he does.

PL/pgSQL is an external shared object, loaded on call of the first func
per backend. Same for PL/Tcl.

PL/pgSQL takes pg_proc.prosrc and compiles all control structures (if,
else, loop) into a form of bytecode. Query strings are left alone until
the statements are actually executed. Tcl has a similar concept of
bytecode compilation.

PL/pgSQL turns all expressions and SQL statements into prepared SPI
plans. It short-circuits simple expressions by directly calling the node
execution, so it works with PostgreSQL's native types and operators.
Here is the big difference, PL/Tcl turns all datums into their external
string representations and then does the Tcl dual-ported-object munging
and math. However, if used right it also offers prepared SPI plans.

If the implementation of functionality results in widely similar code, I
would expect PL/pgSQL and PL/Tcl to perform similar. However, doing the
prepared SPI stuff in Tcl is a bit of work. OTOH doing extensive string
processing in PL/pgSQL is a nightmare. That difference should drive the
decision which language to use when.


Jan


On 10/26/2005 5:48 AM, Marc G. Fournier wrote:

> On Wed, 26 Oct 2005, Michael Fuhr wrote:
>
>> On Wed, Oct 26, 2005 at 12:58:13AM -0300, Marc G. Fournier wrote:
>>> Does anyone know of, or have, any comparisions of the overhead going with
>>> something like pl/perl or pl/php vs using pl/pgsql?

>>
>> Benchmark results will probably depend on the type of processing
>> you're doing. I'd expect PL/pgSQL to be faster at database operations
>> like looping through query results, and other languages to be faster
>> at non-database operations like text munging and number crunching,
>> depending on the particular language's strengths.
>>
>> [Does quick test.]
>>
>> Whale oil beef hooked. PL/pgSQL just outran PL/Perl when I expected
>> the latter to win. Hang on, let me play with it until it comes back
>> with the results I want....

>
> 'k, let's repharase the questions
>
> Overall, I'd expect pl/pgsql to have less overhead, since its "built into"
> the server ... in the case of something like pl/php or pl/perl, assuming
> that I don't use any external modules, is it just as 'built in', or am I
> effectively calling an external interpreter each time I run that function?
>
> For instance, if there wasn't something like to_char() (thanks for
> pointing that one out), then i could write a simple pl/perl function that
> 'simulated it', but itself did no db queries just a simple:
>
> RETURN sprintf("%04d", intval);
>
> Don't know if that made much more sense ... ?
>
>
> ----
> Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
> Email: scrappy@hub.org Yahoo!: yscrappy ICQ: 7615664
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq



--
#================================================= =====================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================= = JanWieck@Yahoo.com #

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:36 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com