Search Postgresql Archives

Re: Invocation overhead for procedural languages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2008/8/6 Giorgio Valoti <giorgio_v@xxxxxxx>:
> Hi all, I think I've read somewhere in the documentation that the invocation
> of functions written in procedural languages (with the exception of plpgsql)
> incur in performance hit due to the call the language interpreter. Is that
> correct or am I completely off track?

it's depend. Start of interpret is only one overhead. Other is date
conversions to language compatible types (without C and plpgsql).
Only plpgsql share expression evaluation with database, so it's
specific overhead only for plpgsql.

postgres=# create function testpg(a integer) returns integer as
$$begin return 1; end; $$ language plpgsql immutable;
CREATE FUNCTION
postgres=# create function testperl(a integer) returns integer as
$$return 1;$$ language plperl;
CREATE FUNCTION

postgres=# select sum(testperl(i)) from generate_series(1,10000) g(i);
  sum
-------
 10000
(1 row)

Time: 588,649 ms
postgres=# select sum(testpg(i)) from generate_series(1,10000) g(i);
  sum
-------
 10000
(1 row)

Time: 51,214 ms

so in this trivial function is plpgql faster then perl, that is fata morgana :).

first start is diferent:
postgres=# select testpg(1);
 testpg
--------
      1
(1 row)

Time: 3,409 ms
postgres=# select testperl(1);
 testperl
----------
        1
(1 row)

Time: 86,199 ms
second is similar
postgres=# select testperl(1);
 testperl
----------
        1
(1 row)

Time: 1,059 ms
postgres=# select testpg(1);
 testpg
--------
      1
(1 row)

Time: 0,955 ms

but you can load perl after server start - look on preload_libraries
section in postgresql.conf

regards
Pavel Stehule

>
> Thank you in advance
> --
> Giorgio Valoti
> --
> Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux