Re: compare languages

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: compare languages
Дата
Msg-id AANLkTimBmHKW=faNwo+TSGqc0DXqQp4HzJG9dbQQovzz@mail.gmail.com
обсуждение исходный текст
Ответ на compare languages  (pasman pasmański <pasman.p@gmail.com>)
Список pgsql-performance
Hello

it isn't surprise. PL/pgSQL hasn't own arithmetic unit. All
expressions are transformed to simple SELECTs.

Probably you can find a tasks, where Perl should be 10, 100, 1000x
faster than PL/pgSQL - array sort, array creation, ..

On second hand, PL/pgSQL is very fast with embeded SQL.

So if you need to calculate a numeric expensive task, then you need to
use Perl, maybe Python or C. If you need to join a embedded SQL, then
PL/pgSQL is good tool.

Regards

Pavel Stehule

p.s. Once I had to solve very slow statistical analysis. 99% of time
needed a bublesort implemented in PL/pgSQL. When I replaced it by
buildin quicksort in SQL language, the problem was solved.



2011/2/8 pasman pasmański <pasman.p@gmail.com>:
> Hi.
> I do small test of plsql and perl.Result is that perl may be
> 2xfaster in simple loops.
>
>
> CREATE OR REPLACE FUNCTION _.test1()  RETURNS void AS
> $BODY$
> declare  i integer;  j bigint := 0;
> begin
> for i in 1..1000000 loop  j:=j+i; end loop;
> end;
> $BODY$ LANGUAGE plpgsql VOLATILE  COST 100;
>
> "Result  (cost=0.00..0.26 rows=1 width=0) (actual
> time=1382.851..1382.853 rows=1 loops=1)"
> "Total runtime: 1383.167 ms"
>
>
> CREATE OR REPLACE FUNCTION _.test2()  RETURNS void AS
> $BODY$
> $j=0;
> for($i=0;$i<1000000;$i++) {
>    $j = $j + $i;
> }
> $BODY$  LANGUAGE plperlu VOLATILE COST 100;
>
> "Result  (cost=0.00..0.26 rows=1 width=0) (actual
> time=584.272..584.275 rows=1 loops=1)"
> "Total runtime: 584.355 ms"
>
>
> ------------
> pasman
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance
>

В списке pgsql-performance по дате отправления:

Предыдущее
От: pasman pasmański
Дата:
Сообщение: compare languages
Следующее
От: Shaun Thomas
Дата:
Сообщение: Re: Really really slow select count(*)