Re: Stored procedures when and how: was: Sun acquires MySQL - Mailing list pgsql-general

From brian
Subject Re: Stored procedures when and how: was: Sun acquires MySQL
Date
Msg-id 47961945.9030200@zijn-digital.com
Whole thread Raw
In response to Re: Stored procedures when and how: was: Sun acquires MySQL  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-general
Pavel Stehule wrote:
>
 > ...
>
> bottleneck is in repeated assign s := s || ..
>
> I will try trick:
>
> create or replace function list(int)
> returns varchar as $$
>  begin
>    return array_to_string(array(select '<item>' || i || '</item>'
> from generate_series(1, $1) g(i)), '');
>  end$$ language plpgsql immutable;
>
> test
> 100, 1.3ms
> 1000, 7.64ms
> 10000, 63ms -- nice I don't need C
> 100000, 350ms
> Regards
>
> Pavel Stehule
>

That's some trick! Thanks for the lessons, Pavel.

b

pgsql-general by date:

Previous
From: "Pavel Stehule"
Date:
Subject: Re: Selecting max(pk) is slow on empty set
Next
From: "Adam Rich"
Date:
Subject: altering foreign keys